using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using BCW.GameTypes.SkyBlock;
using ExitGames.Client.Photon;
using Holoville.HOTween;
using Holoville.HOTween.Core;
using Holoville.HOTween.Plugins;
using I2.Loc;
using UnityEngine;
using UnityEngine.SceneManagement;

public class PlayerBehavior : Humanoid
{
	public delegate void PlayerEvents();

	public const int DefaultHumanHeight = 3;

	public const float shootPointOffset = 1f;

	public Vector3 lastPosition = Vector3.zero;

	public float traveledDistanceOnFoot;

	public float traveledDistanceInCar;

	public float traveledDistanceInWater;

	public float traveledDistanceInAir;

	public GameObject redFlag;

	public GameObject blueFlag;

	[Header("Свойства, которые хранятся в PhotonPlayer для игрока")]
	public PhotonPlayerProps props;

	[Space(10f)]
	public GameObject headCollider;

	public Collider bodyCollider;

	public GameObject CarHitCollider;

	public List<PlayerCollider> collidersOnPlayer = new List<PlayerCollider>();

	public GameObject playerMesh;

	private GameObject buttonEnableCar;

	private GameObject nearestCar;

	public new GameObject prefabPlayer;

	[HideInInspector]
	public GameObject enemyCollider;

	[HideInInspector]
	public EnemyWatcher enemyWatcher;

	private CharacterController cController;

	public ThirdPersonController tController;

	private int idMachine = -9999;

	public WeaponManager weaponManager;

	private float timeLastPlayDamage;

	private float timeDelayBetweenPlayDamage = 0.3f;

	public GameObject playerNameLabel;

	[HideInInspector]
	public GameObject bloodParticle;

	public GameObject wallParticle;

	public GameObject electroshockParticle;

	public GameObject hole;

	public GameObject objArmor;

	public LayerMask collisionLayer;

	public LayerMask collisionLayerForDive;

	private bool waitMoveForOnGravity = true;

	public int level;

	public LayerMask weaponLayers;

	public float currentArmorPercentages;

	public int points;

	public int respect;

	public int indPlayer = -1;

	private int _sessionCupsCount;

	private bool _isShooting;

	[HideInInspector]
	public bool isGetOutCarForOffline;

	public bool isShock;

	public bool damageFromCar;

	public bool _inWater;

	public bool _isGrounded;

	public float rayChkGroundTypeDest = 0.3f;

	public PunTeams.Team localTeam;

	private bool _inParom;

	public GameObject playerParom;

	public NavigationByPoints playerParomNavigation;

	public EntityBehavior currentCar;

	[HideInInspector]
	public EntityBehavior carIWantGet;

	public GameObject[] arrGameObjInPlayer;

	public PlayerAreaBehavior areaBehavior;

	private carDamageEnemy carDemage;

	[HideInInspector]
	public CapsuleCollider colliderEnemyPlayer;

	public PlayerTransformPhoton lerpScript;

	public BoxCollider colliderForHelicopter;

	public List<OnChargeExplosionWidhDetonator> listDetonatorGrenade = new List<OnChargeExplosionWidhDetonator>();

	public GameObject eCollider;

	public AudioClip soundJump;

	public static string noName = "Loading...";

	private float _carInResponseTime;

	public SkinnedMeshRenderer meshInCam;

	public Color colorDamageRed = Color.red;

	public visibleObjPhoton visibleObjScript;

	[Range(0f, 1f)]
	public float invisibleAlphaForOtherPlayers;

	[Range(0f, 1f)]
	public float invisibleAlphaForOurPlayer;

	public Transform fpsCamPivot;

	public Transform FPSCamParent;

	[HideInInspector]
	public bool FPSCameraEnabled;

	[HideInInspector]
	public bool startPVP;

	public bool IamWinner;

	public GameObject winnerIcon;

	public PlayerNick playerNickLableScript;

	public float timeOfRespawn;

	public float speedModifier = 1f;

	public bool enableWeaponChanged = true;

	private bool isPrivateRoom;

	public TweenScale rewardAnim;

	private float timeRefreshNearestPlayerZone;

	private float startInvisibleTime = -1f;

	public int DeathCount;

	private GameplayEvent reputationReduceEvent;

	private bool playerDeadReputationReduce;

	[HideInInspector]
	public bool currentAimMode;

	private Ray ray = default(Ray);

	private RaycastHit hits;

	private SpawnPointChief.SpawnPoint point;

	private bool firstSpawnInLeague;

	private bool initial = true;

	private bool _closeToMine;

	public float minDistance = 125f;

	private float _minSqrDistance;

	private Coroutine SearchingClosePlayersCoroutine;

	private ControllsModifire _iamStair;

	private IEnumerator _loadGroundNearPoint;

	private Coroutine _ifGroundNearPointError;

	private float radiusCController;

	private float heightCController;

	public bool visible = true;

	public bool isNeedGetOut;

	private float becomeLeaderTime;

	private float _leaderTime;

	private bool _imLeader;

	public int myPlayerPlace;

	public Dictionary<int, int> victinIDs = new Dictionary<int, int>();

	private bool checkDead;

	[HideInInspector]
	public OpticalAIMShower opticalAimer;

	public List<OnChargeMine> listDetonatorMine = new List<OnChargeMine>();

	private bool _isDiving;

	public string currentLadderName;

	private bool _onLadder;

	private List<PlayerSpecialProperty> playerSpecialProperties = new List<PlayerSpecialProperty>();

	[HideInInspector]
	public bool enableJetpackUse = true;

	private bool _playerReadyRace;

	public bool recieveRespawnIndex;

	[SerializeField]
	private GameObject pointIndicator;

	[SerializeField]
	private GameObject indicatorObject;

	private Coroutine LerpTransformEnablerCoroutine;

	private PointerPanel _pointer;

	private PointerPanel _backgroundPoint;

	[SerializeField]
	private Transform _pointerIndicator;

	[HideInInspector]
	public string nick
	{
		get
		{
			return props.nickname;
		}
	}

	public override int health
	{
		get
		{
			return base.health;
		}
		set
		{
			if (value > maxHealth)
			{
				value = maxHealth;
			}
			base.health = value;
			if (base.isMine)
			{
				if (GameTopWindow.instance != null && GameController.instance.curTypeGame != TypeGame.tanks && GameController.instance.curTypeGame != TypeGame.WalkingRobots)
				{
					GameTopWindow.instance.SetHealthValue(base.health, maxHealth);
				}
				if (rednessScreen.inst != null && PlayerBehavior.Redness != null)
				{
					PlayerBehavior.Redness(value);
				}
			}
		}
	}

	public override int armor
	{
		get
		{
			return base.armor;
		}
		set
		{
			base.armor = value;
			if ((settings.offlineMode || base.photonView.isMine) && GameTopWindow.instance != null && GameController.instance.curTypeGame != TypeGame.tanks && GameController.instance.curTypeGame != TypeGame.WalkingRobots)
			{
				GameTopWindow.instance.SetArmorValue(value, maxArmor);
			}
		}
	}

	public int sessionCupsCount
	{
		get
		{
			if (base.isMine)
			{
				return CupsManager.SesionCupsCount;
			}
			return _sessionCupsCount;
		}
		set
		{
			if (value != _sessionCupsCount)
			{
				int num = value - _sessionCupsCount;
				_sessionCupsCount = value;
				RiseEvent(this, "SessionCupsChanged", _sessionCupsCount, num);
				if (PvPLeaderbord.instance != null)
				{
					PvPLeaderbord.instance.Refrash();
				}
			}
			_sessionCupsCount = value;
		}
	}

	public bool isShootingFlow
	{
		get
		{
			BaseWeapon currentWeaponScript = weaponManager.currentWeaponScript;
			bool flag = currentWeaponScript != null && currentWeaponScript.weaponType == WeaponType.ShortRange;
			return _isShooting && !weaponManager.currentWeaponScript.isReloading && (!weaponManager.currentWeaponScript.NoAmmo || flag);
		}
	}

	public bool isShooting
	{
		get
		{
			if (weaponManager.currentWeaponScript == null)
			{
				return false;
			}
			mecanimWrapper.HoldShoot(_isShooting && !weaponManager.currentWeaponScript.isReloading);
			return _isShooting && !weaponManager.currentWeaponScript.isReloading;
		}
		set
		{
			if (weaponManager.currentWeaponScript != null)
			{
				_isShooting = value && !weaponManager.currentWeaponScript.isReloading;
				mecanimWrapper.HoldShoot(_isShooting);
			}
		}
	}

	public bool inWater
	{
		get
		{
			return _inWater;
		}
		set
		{
			if (_inWater != value)
			{
				if (onLadder)
				{
					_inWater = false;
				}
				else
				{
					_inWater = value;
				}
				RefreshWaterState();
			}
		}
	}

	public bool isGrounded
	{
		get
		{
			return _isGrounded;
		}
		set
		{
			if (_isGrounded != value)
			{
				_isGrounded = value;
				if (base.isMine)
				{
					tController.mecanimWrapper.isGrounded = value;
				}
			}
		}
	}

	public bool inParom
	{
		get
		{
			return _inParom;
		}
		set
		{
			if (_inParom == value)
			{
				return;
			}
			if (!value)
			{
				GetPlayerParomNavigation();
				if (playerParomNavigation != null)
				{
					playerParomNavigation.Leave(base.gameObject);
				}
				playerParomNavigation = null;
			}
			else if (value && playerParom == null)
			{
				return;
			}
			_inParom = value;
			mecanimWrapper.inParent = value;
			mecanimWrapper.parentObjectTransform = ((!value) ? null : playerParom.gameObject.transform);
		}
	}

	public float invisibleAlpha
	{
		get
		{
			if (settings.offlineMode || base.photonView.isMine)
			{
				return invisibleAlphaForOurPlayer;
			}
			return invisibleAlphaForOtherPlayers;
		}
	}

	public static PlayerBehavior MyPlayer
	{
		get
		{
			if (GameController.instance != null)
			{
				return GameController.instance.playerScript;
			}
			return null;
		}
	}

	public bool closeToMine
	{
		get
		{
			return _closeToMine;
		}
		set
		{
			if (_closeToMine != value || initial)
			{
				initial = false;
				_closeToMine = value;
				if (value)
				{
					AddToActualPlayer();
					UpdatePlayer();
				}
				else
				{
					AddToIgnoredPlayer();
				}
			}
		}
	}

	private float minSqrDistance
	{
		get
		{
			if (_minSqrDistance == 0f)
			{
				_minSqrDistance = minDistance * minDistance;
			}
			return _minSqrDistance;
		}
	}

	public ControllsModifire iamStair
	{
		get
		{
			if (_iamStair == null)
			{
				_iamStair = GetComponent<ControllsModifire>();
			}
			return _iamStair;
		}
	}

	public bool jetpackShow
	{
		get
		{
			return tController.jetpack.activated;
		}
		set
		{
			if (value)
			{
				ActivateJetpack();
			}
			else
			{
				DeactivateJetpack();
			}
		}
	}

	public bool jetpackParticleShow
	{
		get
		{
			return tController.jetpack.particles;
		}
		set
		{
			if (value)
			{
				EnableJetpackParticle();
			}
			else
			{
				DisableJetpackParticle();
			}
		}
	}

	public float leaderTime
	{
		get
		{
			if (MyPlayer == this)
			{
				if (becomeLeaderTime > 0f)
				{
					return CupsManager.LeaderTime + Time.time - becomeLeaderTime;
				}
				return CupsManager.LeaderTime;
			}
			return 0f;
		}
		set
		{
			if (MyPlayer == this)
			{
				CupsManager.LeaderTime = value;
			}
		}
	}

	public bool imLeader
	{
		get
		{
			return _imLeader;
		}
		set
		{
			if (base.isMine)
			{
				GameTopWindow.instance.ShowLeaderIcon(value);
			}
			if (value)
			{
				if (MyPlayer != this)
				{
					iconMiniMap.SetType("Player_Leader");
					PointerPlayer(0, "Icon_Leader", true, true);
				}
				if (_imLeader != value)
				{
					leaderTime = leaderTime;
					becomeLeaderTime = Time.time;
					GameTopWindow.instance.SetLeader(this);
				}
				foreach (PlayerBehavior listPlayer in GameController.instance.listPlayers)
				{
					if (listPlayer != this)
					{
						listPlayer.imLeader = false;
					}
				}
			}
			else
			{
				if (MyPlayer != this)
				{
					PointerPlayer(0, "Icon_Leader", false);
					if (inCar || inHelic)
					{
						iconMiniMap.SetType("CarWithPlayer");
					}
					else
					{
						iconMiniMap.SetType("Enemy");
					}
				}
				leaderTime = leaderTime;
				becomeLeaderTime = 0f;
			}
			_imLeader = value;
		}
	}

	public int Points
	{
		get
		{
			return points;
		}
		set
		{
			if (points == value)
			{
				return;
			}
			int num = value - points;
			points = value;
			if (points < 0)
			{
				points = 0;
			}
			if (PvPLeaderbord.instance != null)
			{
				PvPLeaderbord.instance.Refrash();
			}
			RiseEvent(this, "PointsChanged", points, num);
			if (base.isMine)
			{
				if (TDMController.isTeamGameType)
				{
					TDMController.instance.SetPlayerPoint(base.photonPlayer, value);
				}
				GameTopWindow.instance.Points = points;
				GameTopWindow.instance.lbKillPVP.text = points.ToString();
				if (!controllerConnectGame.reconnectRoom && num > 0)
				{
					settings.updateKolKillPVP(num);
					settings.WeekCountKillPVP += num;
				}
			}
		}
	}

	public string Nick
	{
		get
		{
			return nick;
		}
	}

	public bool onLadder
	{
		get
		{
			return _onLadder;
		}
		set
		{
			_onLadder = value;
			RefreshWaterState();
			SwitchLadder(value);
		}
	}

	public bool playerReadyRace
	{
		get
		{
			return _playerReadyRace;
		}
		set
		{
			_playerReadyRace = value;
		}
	}

	public static event Action<int> Redness;

	public static event PlayerEvents OnDead;

	public event Action refresSpecialProperties;

	public void RefreshWaterState()
	{
		DisableShooting(_onLadder || _inWater);
		if (onLadder)
		{
			mecanimWrapper.inWater = false;
		}
		else
		{
			mecanimWrapper.inWater = _inWater;
		}
	}

	public void GetPlayerParomNavigation()
	{
		if (playerParom != null)
		{
			playerParomNavigation = playerParom.GetComponent<NavigationByPoints>();
			if (playerParomNavigation == null)
			{
				playerParomNavigation = playerParom.GetComponentInParent<NavigationByPoints>();
			}
		}
	}

	public override void Init()
	{
		base.Init();
		InitEvents(new string[5] { "EndGetOutOfCar", "PointsChanged", "SessionCupsChanged", "OnPlayerDeath", "OnPlayerRespawn" });
	}

	public override void Awake()
	{
		base.Awake();
		cController = GetComponent<CharacterController>();
		tController = GetComponent<ThirdPersonController>();
		if (!settings.offlineMode)
		{
			props = new PhotonPlayerProps(base.photonView.owner.customProperties, this);
			StartCoroutine(UpdatePropsInEditor());
		}
		else
		{
			props = new PhotonPlayerProps(new ExitGames.Client.Photon.Hashtable(), this);
		}
		colliderEnemyPlayer = GetComponent<CapsuleCollider>();
		if (lerpScript == null)
		{
			lerpScript = GetComponent<PlayerTransformPhoton>();
		}
		weaponManager = GetComponent<WeaponManager>();
		areaBehavior = GetComponent<PlayerAreaBehavior>();
		if (TutorialManager.TuturialWorking())
		{
			UnityEngine.Object.Destroy(iconMiniMap);
		}
		if (settings.offlineMode || base.photonView.isMine)
		{
			base.gameObject.name = "MyPlayer_____";
			if ((bool)headCollider)
			{
				headCollider.SetActive(false);
			}
		}
		if (!settings.offlineMode && !base.photonView.isMine)
		{
			Transform[] componentsInChildren = GetComponentsInChildren<Transform>();
			Transform[] array = componentsInChildren;
			foreach (Transform transform in array)
			{
				if (transform.gameObject.layer != 26)
				{
					transform.gameObject.layer = 12;
				}
			}
		}
		if ((bool)CarHitCollider)
		{
			CarHitCollider.layer = 23;
		}
	}

	public void UpdateWearingPropsHashtable()
	{
		PhotonNetwork.player.UpdateProperty(PlayerPropsKeys.armor, MarketController.Instance.GetEquipedProduct("Body"));
		PhotonNetwork.player.UpdateProperty(PlayerPropsKeys.hat, MarketController.Instance.GetEquipedProduct("Hats"));
		PhotonNetwork.player.UpdateProperty(PlayerPropsKeys.boots, MarketController.Instance.GetEquipedProduct("Boots"));
	}

	private IEnumerator UpdatePropsInEditor()
	{
		while (true)
		{
			yield return new WaitForSeconds(1f);
			if (props != null && !(base.photonView == null) && base.photonView.owner != null && base.photonView.owner.customProperties != null)
			{
				props.Update(base.photonView.owner.customProperties);
			}
		}
	}

	public static bool IsMyCurrentVehicle(EntityBehavior vehicle)
	{
		return MyPlayer != null && MyPlayer.currentCar != null && MyPlayer.currentCar == vehicle;
	}

	public override void Start()
	{
		if (LerpTransformEnablerCoroutine != null)
		{
			GameController.instance.StopCoroutine(LerpTransformEnablerCoroutine);
		}
		LerpTransformEnablerCoroutine = GameController.instance.StartCoroutine(LerpTransformEnabler());
		if (PhotonNetwork.isMasterClient && PixelmonController.instance != null && GameController.instance != null && GameController.instance.curTypeGame == TypeGame.Pixelmon)
		{
			PhotonPlayer photonPlayer = PhotonPlayer.Find(base.photonView.ownerId);
			PixelmonController.instance.ConnectNewPlayer(photonPlayer);
		}
		base.Start();
		RoomIsPrivate();
		if (base.isMine)
		{
			iconMiniMap.type = 1;
		}
		else
		{
			iconMiniMap.type = 2;
		}
		timeLastPlayDamage = Time.timeSinceLevelLoad;
		eCollider = base.transform.Find("enemyCollider").gameObject;
		if (settings.offlineMode)
		{
			initOfflinePlayer();
			if (FPSCameraEnabled)
			{
				SetVisiblePlayerBesidesControl(visible);
			}
		}
		else
		{
			indPlayer = base.photonView.viewID;
			initPlayerObject();
			if (!base.photonView.isMine)
			{
				if (PrivateCarManager.instance != null && PrivateCarManager.instance.currentCar != null)
				{
					if (GameController.instance != null && GameController.instance.curTypeGame != TypeGame.WalkingRobots)
					{
						PrivateCarManager.instance.currentCar.ApplyCarUpgradesRPC(Load.LoadString("car"));
					}
					else
					{
						PrivateCarManager.instance.currentCar.ApplyCarUpgradesRPC(settings.SelectedTitanName);
					}
				}
				if (GameController.instance != null && GameController.instance.curTypeGame == TypeGame.TitanfallV2 && TitanSpawner.instance.currentTitan != null)
				{
					TitanSpawner.instance.currentTitan.ApplyCarUpgradesRPC(settings.SelectedTitanName);
				}
				if (GameController.instance.curTypeGame != 0)
				{
					iconMiniMap.enabled = base.photonView.owner.GetValueByKey(PlayerPropsKeys.startPVP, false);
				}
				if (TDMController.isTeamGameType)
				{
					if (IsTeammate(this))
					{
						iconMiniMap.type = 24;
					}
					else
					{
						iconMiniMap.type = 25;
					}
				}
				else if (GameController.instance.curTypeGame == TypeGame.normal)
				{
					if (MyPlayer != this && imLeader)
					{
						iconMiniMap.SetType("Player_Leader");
					}
					else
					{
						iconMiniMap.type = 2;
					}
				}
				else if (GameController.instance.curTypeGame == TypeGame.race)
				{
					iconMiniMap.type = 2;
					iconMiniMap.enabled = false;
				}
			}
		}
		if (GameController.instance != null && GameController.instance.curTypeGame == TypeGame.normal)
		{
			imLeader = IsLeader(this);
		}
		GameController.instance.addPlayerToList(this, nick);
		StartCheckAnimationMove();
		weaponManager.AddEventListener(this, "WeaponChanged", delegate(UnityEngine.Object sendder, object[] args)
		{
			ChangePlayerAnimationSet((BaseWeapon)args[0]);
		}, false);
		if (base.isMine)
		{
			sessionCupsCount = CupsManager.SesionCupsCount;
			weaponManager.AttachShopEvents();
			if (!settings.offlineMode)
			{
				ToggleSearchingClosePlayers(true);
			}
			SetVisiblePlayerBesidesControl(GameController.instance.curTypeGame != TypeGame.race && GameController.instance.curTypeGame != TypeGame.WalkingRobots && GameController.instance.curTypeGame != TypeGame.tanks && base.transform.position != Vector3.up * 1000f);
		}
		if (TDMController.isTeamGameType && GameController.instance.curTypeGame != TypeGame.Zombe && base.isMine)
		{
			SetActiveComponentBesidesControl(false);
		}
		Collider[] componentsInChildren = base.gameObject.GetComponentsInChildren<Collider>(true);
		for (int i = 0; i < componentsInChildren.Count(); i++)
		{
			PlayerCollider playerCollider = new PlayerCollider();
			playerCollider.SaveProperties(componentsInChildren[i]);
			collidersOnPlayer.Add(playerCollider);
		}
	}

	private void RoomIsPrivate()
	{
		if (Load.LoadString(settings.keyRoomPass) == string.Empty)
		{
			isPrivateRoom = false;
		}
		else
		{
			isPrivateRoom = true;
		}
	}

	public void SetPlayerLastDamageInfo(Mortal target, bool isHeadshot)
	{
		int playerID = 0;
		float timeFromRespawn = -1f;
		float num = 0f;
		bool headshot = isHeadshot;
		bool invisible = false;
		bool victimJetpack = false;
		bool killerJetpack = false;
		bool isChating = false;
		bool sniperMod = false;
		if (opticalAimer != null)
		{
			sniperMod = opticalAimer.sniperMode;
		}
		if (!GameController.instance.playerScript.inCar)
		{
			killerJetpack = !GameController.instance.playerScript.isGrounded;
		}
		if ((bool)target.GetComponent<PlayerBehavior>())
		{
			PlayerBehavior component = target.GetComponent<PlayerBehavior>();
			invisible = component.IsInvisible;
			playerID = component.indPlayer;
			if (!component.inCar && !component.inHelic)
			{
				component.CheckGroundTypeNotMine();
				if (!component.isGrounded && !component.inWater)
				{
					victimJetpack = true;
				}
			}
			timeFromRespawn = component.timeOfRespawn;
		}
		num = Vector3.Distance(GameController.instance.playerScript.transform.position, target.transform.position);
		WeaponType weaponType = weaponManager.currentWeaponScript.weaponType;
		WeaponTypeSpecific weaponTypeSpecific = weaponManager.currentWeaponScript.weaponTypeSpecific;
		if (GameController.instance.playerScript.inCar)
		{
			weaponType = WeaponType.VehicleGun;
			weaponTypeSpecific = WeaponTypeSpecific.Non;
		}
		target.ResetLastDamageInfo(weaponType, weaponTypeSpecific, playerID, timeFromRespawn, num, headshot, invisible, victimJetpack, killerJetpack, isChating, sniperMod);
	}

	public void StartCheckAnimationMove()
	{
		mecanimWrapper.StartCheck(base.mainRender);
	}

	private void initOfflinePlayer()
	{
		ChangeSkin(MarketController.Instance.GetEquipedSkinID());
		cController = GetComponent<CharacterController>();
		prefabPlayer = base.transform.FindChild("player_mecanim").gameObject;
		enemyCollider = base.transform.Find("enemyCollider").gameObject;
		enemyWatcher = enemyCollider.GetComponent<EnemyWatcher>();
		collisionLayer = enemyWatcher.GetComponent<EnemyWatcher>().collisionLayer;
		GetComponent<NavMeshObstacle>().enabled = true;
		tController.jetpack.Activate();
		colliderEnemyPlayer.enabled = false;
		initIntefaceBindings();
		if (tController != null && tController.jetpack != null)
		{
			tController.jetpack.CanBeActivated();
		}
	}

	public override void OnEnable()
	{
		lastPosition = base.transform.position;
		TDMController.ChangeTeam += ChangeTeam;
	}

	public override void OnDisable()
	{
		lastPosition = Vector3.zero;
		TDMController.ChangeTeam -= ChangeTeam;
	}

	private void ChangeTeam()
	{
		StartCoroutine(IChangeTeam());
	}

	private IEnumerator IChangeTeam()
	{
		if (GameController.instance.curTypeGame != TypeGame.Zombe)
		{
			yield break;
		}
		if (TDMController.myTeam == PunTeams.Team.none)
		{
			yield return null;
		}
		if (!base.isMine)
		{
			yield break;
		}
		foreach (PlayerBehavior element in GameController.instance.listPlayers)
		{
			if (!(element != this))
			{
			}
		}
	}

	private void Update()
	{
		if (base.isMine)
		{
			if (!settings.offlineMode && GameController.instance.curTypeGame != TypeGame.Zombe && GameController.instance.curTypeGame != TypeGame.race && GameController.instance.curTypeGame != TypeGame.tanks && PhotonNetwork.isMasterClient && Time.time > timeRefreshNearestPlayerZone + 5f)
			{
				RefreshNearestPlayerZone();
				timeRefreshNearestPlayerZone = Time.time;
			}
			CheckGroundType();
			updateWeapon();
			if (lastPosition != Vector3.zero && isGrounded && !inWater && !inCar)
			{
				traveledDistanceOnFoot += Vector3.Distance(base.transform.position, lastPosition);
			}
			if (lastPosition != Vector3.zero && inWater && !inCar)
			{
				traveledDistanceInWater += Vector3.Distance(base.transform.position, lastPosition);
			}
			if (traveledDistanceOnFoot >= 500f)
			{
				if (AllUnitaryAchievements.instance.TravelOnFoot_10000.Increment((int)traveledDistanceOnFoot))
				{
					StarterPacksManager.instance.giveTravelOnFootPack = true;
				}
				traveledDistanceOnFoot = 0f;
			}
			if (traveledDistanceInWater >= 500f)
			{
				AllUnitaryAchievements.instance.TravelInWater_10000.Increment((int)traveledDistanceInWater);
				traveledDistanceInWater = 0f;
			}
		}
		else
		{
			CheckGroundTypeNotMine();
		}
		if (inCar && base.transform.localPosition != Vector3.zero)
		{
			base.transform.localPosition = Vector3.zero;
			base.transform.localEulerAngles = Vector3.zero;
		}
		lastPosition = base.transform.position;
	}

	private void SetStartInvisibleTime()
	{
		if (startInvisibleTime == -1f)
		{
			startInvisibleTime = Time.time;
		}
	}

	public void HandleInvisibleAchivment()
	{
	}

	public void SwitchAimMod(bool value)
	{
		currentAimMode = value;
		mecanimWrapper.SwitchAim(value);
	}

	private void CheckGroundTypeNotMine()
	{
		float maxDistance = 5f;
		if (inCar || currentCar != null)
		{
			return;
		}
		if (_isDiving)
		{
			inWater = true;
			return;
		}
		ray.origin = base.transform.position;
		ray.direction = Vector3.down;
		if (Physics.Raycast(ray, out hits, maxDistance))
		{
			if (hits.collider.CompareTag("Water"))
			{
				inWater = true;
				isGrounded = true;
			}
			else
			{
				inWater = false;
				isGrounded = true;
			}
		}
		else
		{
			inWater = false;
			isGrounded = false;
		}
	}

	private void CheckGroundType()
	{
		if (!settings.offlineMode && !base.photonView.isMine)
		{
			return;
		}
		if (_isDiving)
		{
			inWater = true;
			return;
		}
		ray.origin = base.transform.position;
		ray.direction = Vector3.down;
		if (Physics.Raycast(ray, out hits, rayChkGroundTypeDest) && !hits.collider.isTrigger)
		{
			if (hits.collider.CompareTag("Water"))
			{
				inWater = true;
				isGrounded = true;
				return;
			}
			if (hits.collider.CompareTag("Parom"))
			{
				if (!inParom)
				{
					playerParom = hits.collider.gameObject;
					GetPlayerParomNavigation();
					playerParomNavigation.Enter(base.gameObject);
					inParom = true;
				}
			}
			else
			{
				inParom = false;
			}
			inWater = false;
			isGrounded = true;
		}
		else
		{
			inWater = false;
			isGrounded = false;
			inParom = false;
		}
	}

	private void updateWeapon()
	{
		if (!(weaponManager == null))
		{
			weaponManager.Shoot(isShooting, GameController.instance.aimHit);
			if (isShooting && !FPSCameraEnabled)
			{
				tController.LookAtTarget();
			}
		}
	}

	public void InvokedUnholdShoot()
	{
		tController.mecanimWrapper.HoldShoot(false);
	}

	private void initIntefaceBindings()
	{
	}

	public GameObject GetLookTarget()
	{
		return (!(enemyWatcher == null)) ? enemyWatcher.lookTarget : null;
	}

	public void SetSkinFromProps(string skinId)
	{
		if (skinId != string.Empty)
		{
			SetSkin(skinId);
		}
	}

	[PunRPC]
	public void ChangeSkin(string id)
	{
		if (equipedSkinID != id && id != string.Empty)
		{
			SetSkin(id);
			if (!settings.offlineMode && base.isMine)
			{
				UpdateSkinProps(id);
				base.photonView.RPC("ChangeSkin", PhotonTargets.Others, id);
			}
		}
	}

	private void UpdateSkinProps(string skinId)
	{
		PhotonNetwork.player.UpdateProperty(PlayerPropsKeys.skin, skinId);
	}

	private void UpdateCarProps(bool inCar, int carId)
	{
		PhotonNetwork.player.UpdateProperty(PlayerPropsKeys.isInCar, inCar);
		PhotonNetwork.player.UpdateProperty(PlayerPropsKeys.carWeAreInId, carId);
	}

	private void initPlayerObject()
	{
		if (base.photonView.isMine)
		{
			ChangeSkin(MarketController.Instance.GetEquipedSkinID());
			prefabPlayer = base.transform.Find("player_mecanim").gameObject;
			enemyCollider = base.transform.Find("enemyCollider").gameObject;
			enemyWatcher = enemyCollider.GetComponent<EnemyWatcher>();
			collisionLayer = enemyWatcher.GetComponent<EnemyWatcher>().collisionLayer;
			colliderEnemyPlayer.enabled = false;
			initIntefaceBindings();
			GetComponent<NavMeshObstacle>().enabled = false;
			if (tController != null && tController.jetpack != null && tController.jetpack.CanBeActivated())
			{
				ActivateJetpack();
			}
		}
		else
		{
			CharacterController component = GetComponent<CharacterController>();
			eCollider.GetComponent<EnemyWatcher>().enabled = false;
			component.enabled = false;
			if (GameController.instance.curTypeGame != TypeGame.race)
			{
				playerNickLableScript.SetLable(this, base.photonView.owner.GetValueByKey(PlayerPropsKeys.nickname, string.Empty));
			}
			if (tController != null && tController.jetpack != null)
			{
				tController.jetpack.reactiveFire.SetActive(false);
			}
		}
	}

	[PunRPC]
	public override void GetDamage(int damage, int damageType, int idKiller, Vector3 positionKiller, Vector3? hitPoint = null)
	{
		if ((inCar && currentCar != null && currentCar.Type != CarType.Motorcycle) || GameController.instance.curTypeGame == TypeGame.race || GameController.instance.curTypeGame == TypeGame.tanks)
		{
			if (damage == 9999 && GameController.instance.curTypeGame != TypeGame.WalkingRobots)
			{
				Kill(idKiller);
			}
			return;
		}
		base.GetDamage(damage, damageType, idKiller, positionKiller, (Vector3?)null);
		if (VolumeController.IsSoundEnable && Time.timeSinceLevelLoad - timeLastPlayDamage > timeDelayBetweenPlayDamage)
		{
			timeLastPlayDamage = Time.timeSinceLevelLoad;
			if (soundsManager != null)
			{
				soundsManager.Damage();
			}
		}
		if (idKiller > 0)
		{
			BackgroundSoundManager.instance.PlayChaising(20f);
		}
	}

	public void PlayerDeadMessage(int idKiller, int idKilled)
	{
		PhotonView playePhotonViewWithID = GameController.instance.GetPlayePhotonViewWithID(idKiller);
		PhotonView playePhotonViewWithID2 = GameController.instance.GetPlayePhotonViewWithID(idKilled);
		if (!(playePhotonViewWithID != null) || !(playePhotonViewWithID2 != null))
		{
			return;
		}
		if (idKiller != idKilled && idKiller > 0 && playePhotonViewWithID != null)
		{
			PlayerBehavior component = playePhotonViewWithID.gameObject.GetComponent<PlayerBehavior>();
			PlayerBehavior component2 = playePhotonViewWithID2.gameObject.GetComponent<PlayerBehavior>();
			string empty = string.Empty;
			if (component != null)
			{
				empty = component.nick;
			}
			else
			{
				GameController.instance.addMessageToList(string.Format(ScriptLocalization.Get("Game_PVP_msg/src_PlayerKilledHimself"), component2.nick));
			}
			string arg = component2.nick;
			GameController.instance.addMessageToList(string.Format(ScriptLocalization.Get("Game_PVP_msg/src_PlayerKilledPlayer"), empty, arg));
		}
		else if (idKiller > 0 && !settings.offlineMode)
		{
			PlayerBehavior component3 = playePhotonViewWithID2.gameObject.GetComponent<PlayerBehavior>();
			string arg2 = component3.nick;
			GameController.instance.addMessageToList(string.Format(ScriptLocalization.Get("Game_PVP_msg/src_PlayerKilledHimself"), arg2));
		}
	}

	public override void ShowNormalDamage()
	{
		if (base.isMine)
		{
			WalkWindow.instance.animDamage();
		}
		base.ShowNormalDamage();
	}

	public void setName(string name)
	{
		name = FilterBadWorld.FilterString(name);
		GameController.instance.addPlayerToList(this, name);
		if (!base.photonView.isMine && !settings.offlineMode && GameController.instance.curTypeGame != TypeGame.race)
		{
			GameController.instance.addMessageToList(string.Format(ScriptLocalization.Get("Game_PVP_msg/src_PlayerJoinedGame"), nick));
		}
	}

	public void UpdateMaxHealth()
	{
		if (GameController.instance.curTypeGame == TypeGame.Zombe)
		{
			float num = (float)MyPlayer.health / (float)MyPlayer.maxHealth;
			float num2 = 1f;
			int num3 = TDMController.instance.CountTeam(PunTeams.Team.blue);
			int num4 = TDMController.instance.CountTeam(PunTeams.Team.red);
			ZombeSettings zombeSettings = (ZombeSettings)settings.GetSettings(TypeGame.Zombe);
			if (MyPlayer.localTeam == PunTeams.Team.blue)
			{
				num2 = zombeSettings.survivorsHealth.Evaluate(num3) * (float)zombeSettings.startHumanHealth;
			}
			else if (MyPlayer.localTeam == PunTeams.Team.red)
			{
				num2 = zombeSettings.zombieHealth.Evaluate(num4) * (float)zombeSettings.startZombieHealth;
			}
			num2 *= (float)(num3 + num4) / (float)((ZombeSettings)settings.GetSettings(TypeGame.Zombe)).maxPlayers;
			MyPlayer.maxHealth = Mathf.RoundToInt(num2);
			MyPlayer.health = Mathf.RoundToInt(num2 * num);
			if (this == MyPlayer)
			{
				lerpScript.incrementHealth++;
			}
		}
	}

	[PunRPC]
	public override void Kill(int iKillerId = -9999)
	{
		if (GameController.instance.curTypeGame == TypeGame.RocketLeague || !GameController.instance.CanDeadInGame())
		{
			if (settings.offlineMode || !TDMController.isTeamGameType || !PhotonNetwork.isMasterClient)
			{
				return;
			}
			PunTeams.Team team = ((localTeam == PunTeams.Team.blue) ? PunTeams.Team.red : PunTeams.Team.blue);
			if (GameController.instance.curTypeGame != TypeGame.SkyBlock)
			{
				if (GameController.instance.curTypeGame == TypeGame.tanks)
				{
					TDMController.instance.AddTeamPoints(team, 1);
				}
				else if (GameController.instance.curTypeGame == TypeGame.TDM && BCWFlagController.instance != null)
				{
					TDMController.instance.AddTeamPoints(team, BCWFlagController.instance.pointForKill);
				}
			}
			return;
		}
		if ((settings.offlineMode || base.photonView.isMine) && GameController.instance.curTypeGame != TypeGame.tanks && GameController.instance.curTypeGame != TypeGame.WalkingRobots)
		{
			GameController.instance.switchInterface(false);
		}
		if (isDead)
		{
			return;
		}
		if (settings.offlineMode || (!settings.offlineMode && base.photonView.isMine))
		{
			WeaponTargetDetector.instance.StopWatchEnemyPlayers();
		}
		if (base.isMine)
		{
			if (GameController.instance.curTypeGame == TypeGame.TitanfallV2 && !inCar && TitanSpawner.instance.currentTitan != null && !TitanSpawner.instance.currentTitan.isDead)
			{
				TitanSpawner.instance.currentTitan.PropperlyHideTitan(1.5f);
			}
			PhotonNetwork.player.UpdateProperty(PlayerPropsKeys.killerId, iKillerId);
		}
		if (settings.offlineMode)
		{
			Time.timeScale = 1f;
		}
		base.Kill(iKillerId);
		if (inCar || inHelic)
		{
			if (currentCar != null)
			{
				GetOutOfCar(true);
			}
			inCar = false;
			inHelic = false;
		}
		SwitchOnPlayerColliders(false);
		isShooting = false;
		PlayerDeadMessage(iKillerId, base.viewId);
		if (base.isMine)
		{
			BCWStorage.Set("PlayerDeaths", BCWStorage.Get<int>("PlayerDeaths") + 1, true);
			if (GameController.instance.curTypeGame == TypeGame.SkyBlock)
			{
				SwitchFlag(false);
				SkyBlockController.instance.hasFlag = false;
			}
			if (GameController.instance.playerScript.photonView.viewID == iKillerId || iKillerId == -9999 || iKillerId == -99999)
			{
				reputationReduceEvent = AllKillEvents.instance.killdMyself;
				CupsManager.OnPlayerKilledHimself(!settings.offlineMode);
				playerDeadReputationReduce = true;
			}
			else
			{
				reputationReduceEvent = AllKillEvents.instance.killdMe;
				CupsManager.OnPlayerDeath(!settings.offlineMode);
				playerDeadReputationReduce = true;
			}
			MarketControllerUI.instance.ShowDiedMessege(true);
			if ((bool)WalkWindow.instance)
			{
				GameTopWindow.instance.isDeath = true;
			}
		}
		if (!settings.offlineMode)
		{
			if (TDMController.isTeamGameType && PhotonNetwork.isMasterClient)
			{
				PunTeams.Team team2 = ((localTeam == PunTeams.Team.blue) ? PunTeams.Team.red : PunTeams.Team.blue);
				switch (GameController.instance.curTypeGame)
				{
				case TypeGame.tanks:
					TDMController.instance.AddTeamPoints(team2, 1);
					break;
				case TypeGame.Pixelmon:
					if (PixelmonController.instance != null)
					{
						PixelmonController.instance.DropPixelmonFromPlayer(this);
					}
					break;
				}
				if (GameController.instance.IsFlagGameType() && BCWFlagController.instance != null)
				{
					TDMController.instance.AddTeamPoints(team2, BCWFlagController.instance.pointForKill);
				}
			}
			if (!base.isMine)
			{
				DeadTexture(true);
				if (GameController.instance.playerScript.photonView.viewID == iKillerId)
				{
					GameplayEventsManager.instance.NewOnlineKill(lastDamageInfo.weaponType, lastDamageInfo.weaponTypeSpecific, lastDamageInfo.distance, indPlayer, lastDamageInfo.timeOfRespawn, lastDamageInfo.headshot, lastDamageInfo.invisible, lastDamageInfo.victimJetpack, lastDamageInfo.killerJetpack, lastDamageInfo.isChating, lastDamageInfo.sniperMod);
					CupsManager.OnKillPlayer();
					GameController.instance.playerScript.OnKillOnlinePlayer(base.photonView.viewID);
					if (MyPlayer != null && MyPlayer.currentCar != null && MyPlayer.currentCar is TitanBehavior)
					{
						Dictionary<string, string> dictionary = new Dictionary<string, string>();
						dictionary.Add("Titan_kill_stats", MyPlayer.currentCar.name);
						FlurryWrapper.LogEvent(FlurryWrapper.EV_TITANFALL_STATS, dictionary);
					}
				}
				else if (lastDamageInfo.weaponType != WeaponType.Non && lastDamageInfo.playerID != iKillerId)
				{
					ResetLastDamageInfo(WeaponType.Non, WeaponTypeSpecific.Non, -1, 0f, 0f, false, false, false, false, false, false);
				}
			}
			else
			{
				if (PixelmonController.instance != null)
				{
					PixelmonController.instance.hasPixelmon = false;
				}
				CameraModeControl.instance.OnDeath();
				if (PlayerBehavior.OnDead != null)
				{
					PlayerBehavior.OnDead();
				}
				DeathCount++;
			}
		}
		if (settings.offlineMode && PlayerBehavior.OnDead != null)
		{
			PlayerBehavior.OnDead();
		}
		if (base.photonView.isMine && !settings.offlineMode && iKillerId != base.viewId && iKillerId > 0)
		{
			bonuseManager.thisScript.GenerateBonusesForKillingPlayer(base.transform.position, isPrivateRoom);
		}
		settings.updateKolDead(settings.tekKolDead + 1);
		if (weaponManager == null)
		{
			weaponManager = GetComponent<WeaponManager>();
		}
		if (!mecanimWrapper.DeadAnimIsPlayed)
		{
			if (weaponEffectWatcher.currentEffects.Count == 0)
			{
				ShowKill(DamageType.Non);
			}
			else
			{
				ShowKill(weaponEffectWatcher.currentEffects[0].settings.damageType);
			}
		}
		GameController.instance.offlineKolDied++;
		RiseEvent(this, "OnPlayerDeath", iKillerId);
		CoroutineRunner.Invoke(0.5f, delegate
		{
			if (TDMController.instance != null)
			{
				TDMController.instance.CheckPlayerTeam(this);
			}
			ResetThemAll(timeForRespawn);
		});
		if (base.isMine)
		{
			if ((bool)WalkWindow.instance)
			{
				GameTopWindow.instance.isDeath = true;
			}
			if (GameController.instance.curTypeGame == TypeGame.CopsAndRobbers)
			{
				CopsAndRobbersController.instance.SetPlayerInventoryAccordingToTeam(true);
			}
		}
	}

	public float GetTimeForRespawn()
	{
		return timeForRespawn;
	}

	public void FirstSpawn(float resetTime)
	{
		if (base.isMine && !PhotonNetwork.isMasterClient && !settings.offlineMode)
		{
			base.photonView.RPC("ResetThemAll", PhotonNetwork.masterClient, resetTime);
		}
		ResetThemAll(resetTime);
	}

	[PunRPC]
	public void ResetThemAll(float resetTime = 2f)
	{
		if (base.isMine || PhotonNetwork.isMasterClient)
		{
			point = GetPoint(this);
		}
		else
		{
			BCWDebug.LogError("RESETTHEMALL UP 1000");
			point.rotation = Quaternion.identity;
			point.position = Vector3.down * 1000f;
		}
		if (PhotonNetwork.isMasterClient && !settings.offlineMode && !base.isMine)
		{
			base.photonView.RPC("SetPointFromMaster", base.photonView.owner, point.position, point.rotation);
		}
		if (SceneManager.GetActiveScene().name == "Tutorial")
		{
			Invoke("resetLocal", 0f);
		}
		else
		{
			Invoke("resetLocal", resetTime);
		}
	}

	public SpawnPointChief.SpawnPoint GetPoint(PlayerBehavior player)
	{
		if (GameController.instance.curTypeGame == TypeGame.Zombe)
		{
			return SpawnPointChief.instance.getRandomPointForTDM(player);
		}
		if (GameController.instance.curTypeGame == TypeGame.SkyBlock)
		{
			return SpawnPointChief.instance.GetRandomPointForSkyBlock(player);
		}
		if (GameController.instance.curTypeGame == TypeGame.TDM || GameController.instance.curTypeGame == TypeGame.RocketLeague)
		{
			return SpawnPointChief.instance.getRandomPointForTDM(player);
		}
		if (GameController.instance.curTypeGame == TypeGame.CopsAndRobbers)
		{
			return SpawnPointChief.instance.getRandomPointForCopsNRobbers(player);
		}
		if (GameController.instance.curTypeGame == TypeGame.tanks)
		{
			return SpawnPointChief.instance.getRandomPointForTDM(player);
		}
		if (GameController.instance.curTypeGame == TypeGame.Pixelmon)
		{
			return SpawnPointChief.instance.GetRandomPointForPixelmon(player);
		}
		if (GameController.instance.curTypeGame == TypeGame.WalkingRobots)
		{
			return SpawnPointChief.instance.getRandomPointForTDM(player);
		}
		if (GameController.instance.curTypeGame == TypeGame.TitanfallV2)
		{
			return SpawnPointChief.instance.GetRandomPointForTitanFallV2(player);
		}
		return SpawnPointChief.instance.getRandomPointNearPlayer(player);
	}

	public void OnKillOnlinePlayer(int victinId)
	{
		if (base.photonView.isMine)
		{
			if (GameController.instance != null && GameController.instance.curTypeGame != TypeGame.Pixelmon)
			{
				Points++;
			}
			if (!settings.offlineMode && GameController.instance.curTypeGame == TypeGame.normal)
			{
				imLeader = IsLeader(this);
			}
			if (victinIDs.ContainsKey(victinId))
			{
				victinIDs[victinId] += 1;
			}
			else
			{
				victinIDs.Add(victinId, 1);
			}
			ManagerMissions.OnKillPlayer();
		}
	}

	public override void ShowKill(DamageType damage)
	{
		weaponManager.SetVisibleWeapon(false);
		base.ShowKill(damage);
		if (GameController.instance.curTypeGame == TypeGame.CopsAndRobbers)
		{
			PunTeams.Team playerTeam = localTeam;
			timeForRespawn += CopsAndRobbersController.instance.GetRespawnTime(playerTeam);
		}
		CancelInvoke("resetLocal");
		Invoke("resetLocal", timeForRespawn);
	}

	public void reset(bool RestartTDM = false)
	{
		SpawnPointChief.SpawnPoint spawnPoint = default(SpawnPointChief.SpawnPoint);
		if (RestartTDM)
		{
			spawnPoint = SpawnPointChief.instance.getRandomPointForTDM(MyPlayer);
		}
		else if (GameController.instance.curTypeGame == TypeGame.tanks)
		{
			spawnPoint.rotation = Quaternion.identity;
			BCWDebug.LogError("reset UP 1000");
			spawnPoint.position = Vector3.down * 1000f;
		}
		else
		{
			spawnPoint = SpawnPointChief.instance.getRandomPointNearPlayer(MyPlayer);
		}
		reset(spawnPoint.position, spawnPoint.rotation);
	}

	[PunRPC]
	public void SetPointFromMaster(Vector3 position, Quaternion rotation)
	{
		point = default(SpawnPointChief.SpawnPoint);
		point.position = position;
		point.rotation = rotation;
	}

	public void resetLocal()
	{
		if (GameController.instance.curTypeGame == TypeGame.RocketLeague && !firstSpawnInLeague)
		{
			if (base.isMine)
			{
				RocketLeagueCotroller.instance.RepositionCar(point);
			}
		}
		else if (base.isMine)
		{
			firstSpawnInLeague = true;
			Respawn(point.position, point.rotation);
		}
		else
		{
			firstSpawnInLeague = true;
			Respawn(Vector3.up * 1000f, point.rotation);
		}
	}

	[PunRPC]
	public void reset(Vector3 position, Quaternion rotation)
	{
		if (base.isMine && !settings.offlineMode)
		{
			base.photonView.RPC("reset", PhotonTargets.Others, position, rotation);
		}
		Respawn(position, rotation);
	}

	private void AddToActualPlayer()
	{
		if (!GameController.instance.actualPlayers.ContainsKey(base.photonView.viewID))
		{
			GameController.instance.actualPlayers.Add(base.photonView.viewID, this);
		}
		if (GameController.instance.ignoredPlayers.ContainsKey(base.photonView.viewID))
		{
			GameController.instance.ignoredPlayers.Remove(base.photonView.viewID);
		}
	}

	private void AddToIgnoredPlayer()
	{
		if (!GameController.instance.ignoredPlayers.ContainsKey(base.photonView.viewID))
		{
			GameController.instance.ignoredPlayers.Add(base.photonView.viewID, this);
		}
		if (GameController.instance.actualPlayers.ContainsKey(base.photonView.viewID))
		{
			GameController.instance.actualPlayers.Remove(base.photonView.viewID);
		}
	}

	public void UpdatePlayer()
	{
		StartCoroutine(UpdateFromProps());
	}

	private IEnumerator UpdateFromProps()
	{
		while (props.skinName == string.Empty || props.nickname == string.Empty)
		{
			yield return null;
		}
		PVPManager.instance.UpdatePlayer(this);
		while (GameController.instance.curTypeGame == TypeGame.Zombe)
		{
			if (props.skinName != string.Empty && MarketController.Instance.products.Count > 0)
			{
				SetSkin(props.skinName);
			}
			yield return null;
		}
	}

	public void ToggleSearchingClosePlayers(bool value)
	{
		if (value)
		{
			if (SearchingClosePlayersCoroutine == null)
			{
				SearchingClosePlayersCoroutine = StartCoroutine(SearchClosePlayers());
			}
		}
		else if (SearchingClosePlayersCoroutine != null)
		{
			StopCoroutine(SearchingClosePlayersCoroutine);
			SearchingClosePlayersCoroutine = null;
		}
	}

	private IEnumerator SearchClosePlayers()
	{
		while (true)
		{
			yield return new WaitForSeconds(1.5f);
			foreach (PlayerBehavior player in GameController.instance.listPlayers)
			{
				if (!player.isMine)
				{
					player.closeToMine = Vector3.SqrMagnitude(player.transform.position - base.transform.position) < minSqrDistance;
				}
			}
		}
	}

	private void ImmediateUpdate(PlayerBehavior player)
	{
		ExitGames.Client.Photon.Hashtable customProperties = player.photonView.owner.customProperties;
		bool flag = customProperties.ContainsKey(PlayerPropsKeys.isInCar) && (bool)customProperties[PlayerPropsKeys.isInCar];
		bool flag2 = player.inCar || player.inHelic;
		if ((flag && !flag2) || (!flag && flag2))
		{
			PVPManager.instance.UpdatePlayer(player);
		}
		int num = ((!customProperties.ContainsKey(PlayerPropsKeys.killerId)) ? (-1) : ((int)customProperties[PlayerPropsKeys.killerId]));
		if (num != -1)
		{
			player.Kill(num);
		}
	}

	public void CancelRespawn()
	{
		CancelInvoke("reset");
		CancelInvoke("resetLocal");
		CancelInvoke("ressurect");
	}

	public void SwitchOnPlayerColliders(bool value)
	{
		if (value)
		{
			foreach (PlayerCollider item in collidersOnPlayer)
			{
				if (item != null && item.collider != null)
				{
					item.collider.enabled = item.isEnabled;
				}
			}
			return;
		}
		foreach (PlayerCollider item2 in collidersOnPlayer)
		{
			if (item2 != null && item2.collider != null)
			{
				item2.isEnabled = item2.collider.enabled;
				item2.collider.enabled = false;
			}
		}
	}

	public void Respawn(Vector3 position, Quaternion rotation)
	{
		DeactivateGrenade();
		DeactivateMine();
		DeleteAllMines();
		MyPlayer.UpdateMaxHealth();
		tController.gravity = 0f;
		Respawn(position);
		DeadTexture(false);
		FullHealthAndArmor();
		base.transform.rotation = rotation;
		CancelRespawn();
		lerpScript.incrementHealth++;
		timeOfRespawn = Time.unscaledTime;
		isImmortal = true;
		carIWantGet = null;
		showOurGunFromRespawnWithoutRPCVseRovnoEdition();
		BackgroundSoundManager.instance.ResetChaising();
		HideOpticalAimer();
		iamStair.Breack();
		if (base.isMine)
		{
			SetVisiblePlayerBesidesControl(GameController.instance.curTypeGame != TypeGame.race && GameController.instance.curTypeGame != TypeGame.tanks && GameController.instance.curTypeGame != TypeGame.WalkingRobots);
			WalkWindow.instance.ChangeColor();
			if (playerDeadReputationReduce)
			{
				if (reputationReduceEvent != null)
				{
					GameplayRewardManager.instance.AddToRewardQueue(reputationReduceEvent, true);
				}
				playerDeadReputationReduce = false;
			}
			GameTopWindow.instance.statsManager.ChangeHealth();
			PhotonNetwork.player.UpdateProperty(PlayerPropsKeys.killerId, -1);
			ActivateJetpack();
			lastPosition = base.transform.position;
			GameplayEventsManager.instance.Reset(false);
			CameraModeControl.instance.OutFromCar();
			CameraModeControl.instance.OnRespawn();
			GameController.instance.StopTimerDeadPlayerInTrasnport();
			GameController.instance.carScript = null;
			tController.enabled = true;
			ActivateJetpack();
			GameTopWindow.instance.freezePanel.SetActive(false);
			GameTopWindow.instance.stunPanel.SetActive(false);
			GameTopWindow.instance.electroPanel.SetActive(false);
			weaponManager.SetAllWeaponStartAmmo();
			if ((bool)WalkWindow.instance)
			{
				GameTopWindow.instance.isDeath = false;
			}
			SwitchOnPlayerColliders(true);
			StartCoroutine(ActivateJoystickAfterPreloadGround(position));
		}
		else
		{
			colliderEnemyPlayer.enabled = true;
			if (settings.offlineMode || GameController.instance.curTypeGame != TypeGame.tanks)
			{
			}
			playerNickLableScript.healthBar.percent = 1f;
		}
		StartCoroutine(WaitAfterSpawn());
		tController.verticalSpeed = 0f;
		tController.moveSpeed = 0f;
		tController.inAirVelocity = Vector3.zero;
		HOTween.Kill(base.transform);
		isShooting = false;
		isShock = false;
		_isDiving = false;
		inHelic = false;
		inWater = false;
		inCar = false;
		currentCar = null;
		lerpScript.enabled = true;
		if (damageFromCar)
		{
			chkWakeUp();
		}
		base.transform.parent = null;
		damageFromCar = false;
		tController.isPlayAnimation = true;
		mecanimWrapper.checkGround = false;
		base.transform.parent = null;
		ResetLastDamageInfo(WeaponType.Non, WeaponTypeSpecific.Non, indPlayer, -1f, 0f, false, false, false, false, false, false);
		if (weaponEffectWatcher != null)
		{
			weaponEffectWatcher.StopAllEffectsImmediate();
		}
		weaponManager.Shoot(false, Vector3.zero);
		mecanimWrapper.Respawn();
		if (base.isMine && GameController.instance.curTypeGame == TypeGame.tanks)
		{
			if (controllerConnectGame.reconnectRoom)
			{
				SpawnPointChief.SpawnPoint spawnPoint = default(SpawnPointChief.SpawnPoint);
				spawnPoint.position = position;
				spawnPoint.rotation = rotation;
				TankBattleController.instance.SpawnTank(spawnPoint);
			}
			else
			{
				TankBattleController.instance.SpawnTank(point);
			}
		}
		else if (base.isMine && GameController.instance.curTypeGame == TypeGame.RocketLeague)
		{
			if (controllerConnectGame.reconnectRoom)
			{
				SpawnPointChief.SpawnPoint spawnPoint2 = default(SpawnPointChief.SpawnPoint);
				spawnPoint2.position = position;
				spawnPoint2.rotation = rotation;
				RocketLeagueCotroller.instance.RepositionCar(spawnPoint2);
			}
			else
			{
				RocketLeagueCotroller.instance.RepositionCar(point);
			}
		}
		else if (base.isMine && GameController.instance.curTypeGame == TypeGame.WalkingRobots)
		{
			if (controllerConnectGame.reconnectRoom)
			{
				TitanfallController.instance.SpawnTitan(new SpawnPointChief.SpawnPoint
				{
					position = position,
					rotation = rotation
				});
			}
			else
			{
				TitanfallController.instance.SpawnTitan(point);
			}
		}
		if (!settings.offlineMode && GameController.instance.curTypeGame == TypeGame.normal)
		{
			foreach (PlayerBehavior listPlayer in GameController.instance.listPlayers)
			{
				listPlayer.imLeader = IsLeader(listPlayer);
			}
		}
		onLadder = false;
		RiseEvent(this, "OnPlayerRespawn");
		Invoke("ressurect", 5f);
	}

	private void UpdateIconMiniMapForZombie()
	{
		if (GameController.instance.curTypeGame != TypeGame.Zombe)
		{
			return;
		}
		if (MyPlayer.localTeam == PunTeams.Team.blue)
		{
			foreach (PlayerBehavior listPlayer in GameController.instance.listPlayers)
			{
				if (!(listPlayer == MyPlayer))
				{
					if (listPlayer.localTeam == PunTeams.Team.blue)
					{
						listPlayer.iconMiniMap.type = 24;
						listPlayer.iconMiniMap.enabled = true;
					}
					else if (listPlayer.localTeam == PunTeams.Team.red)
					{
						listPlayer.iconMiniMap.type = 29;
						listPlayer.iconMiniMap.enabled = false;
					}
				}
			}
			return;
		}
		if (MyPlayer.localTeam != PunTeams.Team.red)
		{
			return;
		}
		foreach (PlayerBehavior listPlayer2 in GameController.instance.listPlayers)
		{
			if (!(listPlayer2 == MyPlayer))
			{
				if (listPlayer2.localTeam == PunTeams.Team.blue)
				{
					listPlayer2.iconMiniMap.type = 24;
					listPlayer2.iconMiniMap.enabled = true;
				}
				else if (listPlayer2.localTeam == PunTeams.Team.red)
				{
					listPlayer2.iconMiniMap.type = 29;
					listPlayer2.iconMiniMap.enabled = true;
				}
			}
		}
	}

	private void UpdateIconForTDM()
	{
		if (GameController.instance.curTypeGame != TypeGame.TDM && GameController.instance.curTypeGame != TypeGame.Pixelmon && GameController.instance.curTypeGame != TypeGame.WalkingRobots)
		{
			return;
		}
		if (MyPlayer.localTeam == PunTeams.Team.blue)
		{
			foreach (PlayerBehavior listPlayer in GameController.instance.listPlayers)
			{
				if (!(listPlayer == MyPlayer))
				{
					if (listPlayer.localTeam == PunTeams.Team.blue)
					{
						listPlayer.iconMiniMap.type = 24;
					}
					else if (listPlayer.localTeam == PunTeams.Team.red)
					{
						listPlayer.iconMiniMap.type = 25;
					}
				}
			}
			return;
		}
		if (MyPlayer.localTeam != PunTeams.Team.red)
		{
			return;
		}
		foreach (PlayerBehavior listPlayer2 in GameController.instance.listPlayers)
		{
			if (!(listPlayer2 == MyPlayer))
			{
				if (listPlayer2.localTeam == PunTeams.Team.blue)
				{
					listPlayer2.iconMiniMap.type = 25;
				}
				else if (listPlayer2.localTeam == PunTeams.Team.red)
				{
					listPlayer2.iconMiniMap.type = 24;
				}
			}
		}
	}

	public void UpdateIconPixelmon(bool catchPixelmon, PunTeams.Team team)
	{
		if (this == MyPlayer)
		{
			return;
		}
		iconMiniMap.enabled = true;
		if (GameController.instance.curTypeGame != TypeGame.Pixelmon)
		{
			return;
		}
		if (catchPixelmon)
		{
			if (MyPlayer.localTeam == team)
			{
				iconMiniMap.SetType("Pixelmon_Our");
			}
			else
			{
				iconMiniMap.SetType("Pixelmon_Enemy");
			}
		}
		else if (MyPlayer.localTeam == PunTeams.Team.blue)
		{
			switch (team)
			{
			case PunTeams.Team.blue:
				iconMiniMap.type = 24;
				break;
			case PunTeams.Team.red:
				iconMiniMap.type = 25;
				break;
			}
		}
		else if (MyPlayer.localTeam == PunTeams.Team.red)
		{
			switch (team)
			{
			case PunTeams.Team.blue:
				iconMiniMap.type = 25;
				break;
			case PunTeams.Team.red:
				iconMiniMap.type = 24;
				break;
			}
		}
	}

	private IEnumerator WaitAfterSpawn()
	{
		yield return new WaitForSeconds(0.5f);
		SetActiveComponentBesidesControl(true);
		yield return null;
		UpdateIconMiniMapForZombie();
		UpdateIconForTDM();
	}

	public void WaitMoveForOnGravity(bool val)
	{
		if (val)
		{
			tController.gravity = 0f;
			StartCoroutine(WaitForJoystick());
		}
		else
		{
			tController.gravity = 20f;
			mecanimWrapper.checkGround = true;
		}
	}

	private IEnumerator ActivateJoystickAfterPreloadGround(Vector3 position)
	{
		if (SceneManager.GetActiveScene().name == "Level1")
		{
			_loadGroundNearPoint = ManagerPreloadingSectors.thisScript.LoadGroundNearPoint(new Vector2(position.x, position.z));
			_ifGroundNearPointError = StartCoroutine(ifGroundNearPointError());
			yield return CoroutineRunner.Instance.StartCoroutine(_loadGroundNearPoint);
			WaitMoveForOnGravity(true);
			StopCoroutine(_ifGroundNearPointError);
			_loadGroundNearPoint = null;
		}
		else
		{
			WaitMoveForOnGravity(true);
		}
	}

	private IEnumerator ifGroundNearPointError()
	{
		float timer = 0f;
		while (timer < 6f)
		{
			timer += 1f;
			yield return new WaitForSeconds(1f);
		}
		if (tController.gravity < 1f)
		{
			if (_loadGroundNearPoint != null)
			{
				StopCoroutine(_loadGroundNearPoint);
				_loadGroundNearPoint = null;
			}
			WaitMoveForOnGravity(true);
		}
	}

	private IEnumerator WaitForJoystick()
	{
		tController.predPos = base.transform.localPosition;
		yield return new WaitForEndOfFrame();
		while (true)
		{
			if (tController != null && tController.joyScript != null)
			{
				Ray toPlayer = new Ray(base.transform.position, base.transform.up * -1f);
				RaycastHit hit;
				if ((tController.predPos != Vector3.zero && !base.transform.localPosition.Equals(tController.predPos)) || tController.joyScript.position.x != 0f || tController.joyScript.position.y != 0f || (Physics.Raycast(toPlayer, out hit, 2f) && (hit.transform.CompareTag("ground") || hit.transform.CompareTag("Untagged"))))
				{
					break;
				}
			}
			yield return new WaitForEndOfFrame();
		}
		tController.enabled = true;
		tController.gravity = 20f;
		tController.mecanimWrapper.checkGround = true;
	}

	private void ressurect()
	{
		if (GameController.instance.curTypeGame == TypeGame.WalkingRobots)
		{
			isImmortal = true;
		}
		else
		{
			isImmortal = false;
		}
		onLadder = false;
		if (base.isMine)
		{
			GameTopWindow.instance.freezePanel.SetActive(false);
			GameTopWindow.instance.stunPanel.SetActive(false);
			GameTopWindow.instance.electroPanel.SetActive(false);
		}
		else
		{
			SwitchOnPlayerColliders(true);
		}
		iconMiniMap.dontShowIcon = false;
	}

	public void GetInCar()
	{
		if (BCWDebug.isDebugBuild)
		{
			BCWDebug.Log("GetInCar");
		}
		if (!inCar && !isDead && !(areaBehavior.nearCar == null) && areaBehavior.nearCar.isFree)
		{
			carIWantGet = null;
			carIWantGet = areaBehavior.nearCar;
			if (!settings.offlineMode && base.isMine)
			{
				base.photonView.RPC("AskGetInCar", PhotonTargets.All, base.viewId, carIWantGet.viewId);
			}
			else
			{
				AskGetInCar(base.viewId, carIWantGet.viewId);
			}
			if (MessageWindow.instance != null && MessageWindow.instance.windowChangeMap != null)
			{
				MessageWindow.instance.windowChangeMap.gameObject.SetActive(false);
			}
		}
	}

	[PunRPC]
	public void AskGetInCar(int inViewId, int inCarId)
	{
		if (!base.isMine)
		{
			GameController.instance.playerScript.AskGetInCar(inViewId, inCarId);
		}
		else if (!(carIWantGet == null))
		{
			if (base.viewId != inViewId && inCarId == carIWantGet.viewId)
			{
				CancelInvoke("IMayGetIn");
				carIWantGet = null;
			}
			else if (base.viewId == inViewId && inCarId == carIWantGet.viewId)
			{
				Invoke("IMayGetIn", 0.5f);
			}
		}
	}

	public void IMayGetIn()
	{
		if (!(carIWantGet == null))
		{
			GetInCarWithConfirmation(base.viewId, carIWantGet.viewId);
			carIWantGet = null;
		}
	}

	[PunRPC]
	public void GetInCarWithConfirmation(int viewId, int carId)
	{
		if (!settings.offlineMode && base.photonView.isMine)
		{
			base.photonView.RPC("GetInCarWithConfirmation", PhotonTargets.Others, viewId, carId);
		}
		else if (GameController.instance.curTypeGame != TypeGame.tanks && GameController.instance.curTypeGame != TypeGame.RocketLeague && GameController.instance.curTypeGame != TypeGame.race && GameController.instance.curTypeGame != TypeGame.WalkingRobots)
		{
			GameController.instance.playerScript.AskGetInCar(viewId, carId);
		}
		if (inCar || inHelic || isDead || viewId != base.viewId)
		{
			return;
		}
		bodyCollider.isTrigger = true;
		EntityBehavior entityBehavior = null;
		foreach (EntityBehavior item in GameController.instance.arrAllCar)
		{
			if (item != null && item.viewId == carId)
			{
				entityBehavior = item;
				break;
			}
		}
		if (entityBehavior == null || entityBehavior.isDead)
		{
			return;
		}
		if (currentCar != null)
		{
			currentCar.RemoveAllEventListeners(this);
		}
		entityBehavior.RemoveAllEventListeners(this);
		isGrounded = false;
		if ((bool)entityBehavior.GetComponent<HelicopterBehavior>())
		{
			inCar = false;
			inHelic = true;
		}
		else
		{
			inCar = true;
			inHelic = false;
		}
		currentCar = entityBehavior;
		if (currentCar.Type != CarType.Motorcycle)
		{
			radiusCController = cController.radius;
			heightCController = cController.height;
			cController.radius = 0.1f;
			cController.height = 0.1f;
		}
		if (BCWDebug.isDebugBuild)
		{
			BCWDebug.Log("GetInCarWithConfirmation: " + currentCar);
		}
		currentCar.AddEventListener(this, "OnGetIn", delegate(UnityEngine.Object sender, object[] args)
		{
			bool left = (bool)args[1];
			bool flag2 = (bool)args[0];
			SetVisiblePlayerBesidesControl(flag2);
			if (flag2)
			{
				mecanimWrapper.GetInCar(left);
			}
			if (!base.isMine)
			{
				lerpScript.enabled = false;
				weaponManager.SetVisibleWeapon(false);
				ResetLastDamageInfo(WeaponType.Non, WeaponTypeSpecific.Non, indPlayer, -1f, 0f, false, false, false, false, false, false);
			}
			else
			{
				if (weaponManager.currentWeaponScript != null && isSniperModeEnabled())
				{
					HideOpticalAimer();
				}
				GameController.instance.dirRotateCar = 0f;
				GameController.instance.carScript = currentCar;
				CameraModeControl.instance.OnEnterCar(currentCar.transform);
				SetActiveComponentBesidesControl(false);
				tController.stamina = 1f;
				UpdateCarProps(true, currentCar.viewId);
				BasicInput.Reset();
			}
			weaponManager.SetVisibleWeapon(false);
		}, true);
		currentCar.AddEventListener(this, "Crush", CrushOnCar, true);
		currentCar.AddEventListener(this, "EndGetIn", delegate(UnityEngine.Object sender, object[] args)
		{
			if (settings.offlineMode && !currentCar.privateCar)
			{
				GameplayEventsManager.instance.NewVehicleStealEvent(VehicleType.Non);
			}
			isShock = false;
			bool flag = (bool)args[0];
			if (weaponManager.currentWeaponScript != null && isSniperModeEnabled())
			{
				HideOpticalAimer();
			}
			weaponManager.SetVisibleWeapon(false);
			lerpScript.enabled = false;
		}, true);
		if (settings.offlineMode || (!settings.offlineMode && base.photonView.isMine))
		{
			if (currentCar.Type == CarType.Tank)
			{
				WeaponTargetDetector.instance.homingAim = false;
				WeaponTargetDetector.instance.StartWatchEnemyPlayers();
			}
			else
			{
				WeaponTargetDetector.instance.StopWatchEnemyPlayers();
			}
		}
		damageFromCar = true;
		currentCar.GetIn(this);
		if (currentCar.Type != CarType.Motorcycle)
		{
			indicatorObject.transform.localPosition = currentCar.carIndicatorHolder.localPosition + Vector3.down * 1.8f;
		}
		entityBehavior = null;
		if (Device.indexWeakDevice == 0 && base.isMine && (currentCar.Type == CarType.Car || currentCar.Type == CarType.Tank) && !currentCar.privateCar && !currentCar.carWithoutShadow)
		{
			currentCar.bcwShadowController.TurnOnEntityShadow(true);
		}
	}

	public override int GetBodyHeight()
	{
		return (base.BodyHeight != 0) ? base.BodyHeight : 3;
	}

	public override Vector3 GetPositionForChargeHit()
	{
		Vector3 position = base.transform.position;
		position.y += 1f;
		return position;
	}

	public void CrushOnCar(object sender, params object[] args)
	{
		int damague = (int)args[0];
		CrushOnCar(damague);
	}

	[PunRPC]
	public void CrushOnCar(int damague)
	{
		SetVisiblePlayerBesidesControl(true);
		HOTween.Kill(base.transform);
		StartCheckAnimationMove();
		if (base.isMine)
		{
			if (!settings.offlineMode)
			{
				base.photonView.RPC("CrushOnCar", PhotonTargets.Others, damague);
			}
			if (!MarketControllerUI.instance.MarketActive())
			{
				GameController.instance.switchInterface(false);
			}
			GameController.instance.carScript = null;
			GameController.instance.StopTimerDeadPlayerInTrasnport();
			pointExitFromCar[] array = currentCar.sitPoints[0].pointExitFromCar;
			foreach (pointExitFromCar pointExitFromCar2 in array)
			{
				if (pointExitFromCar2.point != Vector3.zero)
				{
					base.transform.position = pointExitFromCar2.point;
				}
			}
			Rigidbody component = GetComponent<Rigidbody>();
			colliderEnemyPlayer.enabled = true;
			component.isKinematic = false;
			component.useGravity = true;
			component.velocity = currentCar.GetComponent<Rigidbody>().velocity / 2f;
			component.angularVelocity = Vector3.zero;
			currentCar.ActivateCar(false, -1, true);
			colliderEnemyPlayer.enabled = true;
			GetDamage(damague, 2, currentCar.ownerViewId);
			CameraModeControl.instance.OutFromCar();
			base.transform.eulerAngles = new Vector3(0f, base.transform.eulerAngles.y, 0f);
			UpdateCarProps(false, -1);
		}
		else
		{
			lerpScript.enabled = true;
		}
		if (currentCar != null)
		{
			currentCar.clearSitPoint();
		}
		weaponManager.SetVisibleWeapon(false);
		inCar = false;
		if (base.isMine)
		{
			GameTopWindow.instance.SwitchHealthBarToEntity(false);
		}
		currentCar = null;
		damageFromCar = true;
		Invoke("chkWakeUp", 0.5f);
		isShock = true;
		mecanimWrapper.DropDownMajor();
	}

	private void chkWakeUp()
	{
		Rigidbody component = GetComponent<Rigidbody>();
		if (component.velocity.magnitude < 0.01f)
		{
			Invoke("wakeUpAfterCar", 0.2f);
		}
		else
		{
			Invoke("chkWakeUp", 0.05f);
		}
	}

	public void showOurGun()
	{
		StoptFlickerWhileGettingUp(mainMaterial);
		showOurGunFromRespawnWithoutRPCVseRovnoEdition();
	}

	public void showOurGunFromRespawnWithoutRPCVseRovnoEdition()
	{
		isShock = false;
		tController.jetpack.Activate();
		weaponManager.SetVisibleWeapon(true);
		damageFromCar = false;
		inCar = false;
		currentCar = null;
	}

	private void wakeUpAfterCar()
	{
		if (!base.isMine)
		{
			colliderEnemyPlayer.enabled = true;
		}
		else
		{
			if (!MarketControllerUI.instance.MarketActive())
			{
				CameraModeControl.instance.OutFromCar();
			}
			SetActiveComponentBesidesControl(true);
			colliderEnemyPlayer.enabled = false;
		}
		Invoke("showOurGun", 1.5f);
		mecanimWrapper.StandUp();
	}

	public void SetActiveComponentBesidesControl(bool Val)
	{
		base.enabled = Val;
		if (base.isMine)
		{
			Rigidbody component = GetComponent<Rigidbody>();
			component.isKinematic = true;
			component.useGravity = false;
			component.velocity = Vector3.zero;
			component.angularVelocity = Vector3.zero;
			tController.enabled = Val;
			cController.enabled = Val;
			if (MyPlayer != this && imLeader)
			{
				iconMiniMap.SetType("Player_Leader");
			}
			else if (settings.learningCompleted)
			{
				if (inCar || inHelic)
				{
					iconMiniMap.type = 22;
				}
				else
				{
					iconMiniMap.type = 1;
				}
			}
			GetComponent<LODGroup>().enabled = Val;
		}
		else
		{
			colliderEnemyPlayer.enabled = Val;
			iconMiniMap.enabled = (Val && GameController.instance.curTypeGame == TypeGame.normal) || GameController.instance.curTypeGame == TypeGame.TDM || GameController.instance.curTypeGame == TypeGame.Zombe || GameController.instance.curTypeGame == TypeGame.Pixelmon;
			if (TDMController.isTeamGameType && GameController.instance.curTypeGame != TypeGame.Zombe)
			{
				if (PhotonNetwork.player != null && base.photonView != null && base.photonView.owner != null && IsTeammate(this))
				{
					iconMiniMap.type = 24;
				}
				else
				{
					iconMiniMap.type = 25;
				}
			}
			if ((!base.isMine && GameController.instance.curTypeGame == TypeGame.tanks) || (!base.isMine && base.transform.position.y > 500f))
			{
				iconMiniMap.enabled = false;
			}
		}
		if (eCollider != null)
		{
			eCollider.SetActive(Val);
		}
	}

	public void SetVisiblePlayerBesidesControl(bool Val)
	{
		visible = Val;
		GetComponent<LODGroup>().enabled = Val;
		GameObject[] array = arrGameObjInPlayer;
		foreach (GameObject gameObject in array)
		{
			if (gameObject != null)
			{
				gameObject.SetActive(Val);
			}
		}
		if (base.isMine && WalkWindow.instance != null && PrivateCarManager.instance != null)
		{
			WalkWindow.instance.carSelector.SetVisible(enableWeaponChanged && Val && PrivateCarManager.instance.currentCar != null);
		}
		if (isSniperModeEnabled())
		{
			weaponManager.SetVisibleWeapon(false);
			equipmentManager.VisibleArmor = false;
			mecanimWrapper.PlayerMech.SetActive(false);
			mecanimWrapper.PlayerMechFPS.SetActive(false);
			equipmentManager.SetVisibleEquip(false);
		}
		else
		{
			weaponManager.SetVisibleWeapon(Val);
			equipmentManager.VisibleArmor = Val && !FPSCameraEnabled;
			mecanimWrapper.PlayerMech.SetActive(Val && !FPSCameraEnabled);
			mecanimWrapper.PlayerMechFPS.SetActive(Val && FPSCameraEnabled);
			equipmentManager.SetVisibleEquip(Val && !FPSCameraEnabled);
		}
	}

	private void SetVisibleJetpack(bool value)
	{
		MeshRenderer component = tController.jetpack.gameObject.GetComponent<MeshRenderer>();
		component.enabled = !FPSCameraEnabled && value;
	}

	public void SetVisibleOnlyMeshObjPlayer(bool val)
	{
		SetVisibleJetpack(val);
		SetVisiblePlayerBesidesControl(visible);
	}

	[PunRPC]
	public override void GetOutOfCar(bool withAnim)
	{
		if (settings.offlineMode)
		{
			isGetOutCarForOffline = true;
		}
		if (Device.indexWeakDevice == 0 && base.isMine && (currentCar.Type == CarType.Car || currentCar.Type == CarType.Tank) && !currentCar.privateCar && !currentCar.carWithoutShadow)
		{
			currentCar.bcwShadowController.TurnOnEntityShadow(false);
		}
		if (!settings.offlineMode && base.photonView.isMine)
		{
			base.photonView.RPC("GetOutOfCar", PhotonTargets.Others, withAnim);
		}
		base.GetOutOfCar(true);
		if (!inCar && !inHelic)
		{
			return;
		}
		inCar = false;
		inHelic = false;
		inWater = false;
		isShooting = false;
		if (currentCar.Type != CarType.Motorcycle)
		{
			cController.radius = radiusCController;
			cController.height = heightCController;
		}
		if (this == GameController.instance.playerScript && currentCar != null)
		{
			TPSCamera.instance.HideTankSniperMode();
			isShock = true;
			currentCar.AddEventListener(this, "OnGetOut", delegate(UnityEngine.Object sender, object[] args)
			{
				isShock = true;
				bool flag = (bool)args[1];
				if ((bool)args[0])
				{
					if (!settings.offlineMode && base.photonView.isMine)
					{
						base.photonView.RPC("ShowGetOutOfCarAnim", PhotonTargets.Others, flag);
					}
					mecanimWrapper.GetOutCar(flag);
				}
				UpdateCarProps(false, -1);
				if (currentCar.privateCar)
				{
					Vector3 position = currentCar.transform.position;
					Quaternion rotation = currentCar.transform.rotation;
					PrivateCarManager.instance.UpdatePrivateCarProps(position, rotation, currentCar.viewId);
				}
			}, true);
			currentCar.AddEventListener(this, "EndGetOut", delegate
			{
				isShock = false;
				GameController.instance.carScript = null;
				CameraModeControl.instance.OutFromCar();
				GameController.instance.StopTimerDeadPlayerInTrasnport();
				if (settings.offlineMode || base.photonView.isMine)
				{
					SwitchFPSCameraMode(FPSCameraEnabled);
					if (GameController.instance.curTypeGame != TypeGame.tanks && GameController.instance.curTypeGame != TypeGame.WalkingRobots)
					{
						GameController.instance.switchInterface(false);
					}
				}
				OnEndGetOut();
				isShooting = false;
				damageFromCar = false;
				if ((bool)currentCar)
				{
					currentCar = null;
					currentCar.RemoveAllEventListeners(this);
				}
				RiseEvent(this, "EndGetOutOfCar");
				if (settings.offlineMode)
				{
					isGetOutCarForOffline = false;
				}
			}, true);
			if (!withAnim)
			{
				mecanimWrapper.GetOutCar(true);
			}
			currentCar.GetOut(this, withAnim);
		}
		else
		{
			isShock = false;
			currentCar.AddEventListener(this, "EndGetOut", delegate
			{
				CoroutineRunner.Invoke(0.1f, delegate
				{
					EnableLerpScript();
				});
			});
			currentCar.GetOut(this, withAnim);
			if (!withAnim)
			{
				mecanimWrapper.GetOutCar(true);
			}
			OnEndGetOut();
		}
		indicatorObject.transform.localPosition = Vector3.zero;
		currentCar = null;
	}

	public void EnableLerpScript()
	{
		if (lerpScript != null)
		{
			lerpScript.enabled = true;
		}
	}

	[PunRPC]
	public void ShowGetOutOfCarAnim(bool left)
	{
		mecanimWrapper.GetOutCar(left);
	}

	public void OnEndGetOut()
	{
		SetActiveComponentBesidesControl(true);
		SetVisiblePlayerBesidesControl(GameController.instance.curTypeGame != TypeGame.tanks && GameController.instance.curTypeGame != TypeGame.race && GameController.instance.curTypeGame != TypeGame.WalkingRobots);
		StartCheckAnimationMove();
		weaponManager.SetVisibleWeapon(true);
		tController.jetpack.Activate();
		currentCar = null;
		damageFromCar = false;
		bodyCollider.isTrigger = false;
		weaponManager.ManageHomingAim();
	}

	public void ActivateJetpack()
	{
		if (tController != null && tController.jetpack != null)
		{
			tController.jetpack.Activate();
		}
	}

	public void DeactivateJetpack()
	{
		if (tController != null && tController.jetpack != null)
		{
			tController.jetpack.DeactivateForPhoton();
		}
	}

	public void EnableJetpackParticle()
	{
		if (tController != null && tController.jetpack != null)
		{
			tController.jetpack.ActivateParticles();
			tController.jetpack.reactiveFire.SetActive(true);
		}
	}

	public void DisableJetpackParticle()
	{
		if (tController != null && tController.jetpack != null)
		{
			tController.jetpack.reactiveFire.SetActive(false);
		}
	}

	private bool DamageOnStrikeAccuracy(GameObject curEnemyTarget)
	{
		if (!settings.offlineMode && !base.photonView.isMine)
		{
			return true;
		}
		if (curEnemyTarget == null || weaponManager.currentWeaponScript == null)
		{
			return false;
		}
		float num = Vector3.Distance(curEnemyTarget.transform.position, base.transform.position);
		int num2 = UnityEngine.Random.Range(0, 100);
		if ((float)num2 > weaponManager.currentWeaponScript.spreadWeapon)
		{
			return true;
		}
		return false;
	}

	public bool isSniping()
	{
		return false;
	}

	public bool isSniperModeEnabled()
	{
		return opticalAimer != null && opticalAimer.sniperMode;
	}

	private bool needChangeActivArmor()
	{
		bool flag = Load.LoadBool(settings.keyArmorEnabled);
		if (objArmor.activeSelf && !flag)
		{
			return true;
		}
		if (!objArmor.activeSelf && flag)
		{
			return true;
		}
		return false;
	}

	public bool IsLeader(PlayerBehavior checkPlayer)
	{
		if (GameController.instance.listPlayers.Count < 2)
		{
			return false;
		}
		foreach (PlayerBehavior listPlayer in GameController.instance.listPlayers)
		{
			if (listPlayer != checkPlayer && listPlayer.Points >= checkPlayer.Points)
			{
				return false;
			}
		}
		return true;
	}

	public void UpdateMyPlayerPlace()
	{
		myPlayerPlace = 0;
		if (GameController.instance.curTypeGame != TypeGame.TitanfallV2)
		{
			return;
		}
		if (MyPlayer == null)
		{
			GameInfoWindow.instance.titanfalUI.SetMyPlace(myPlayerPlace);
			return;
		}
		List<PlayerBehavior> listPlayers = GameController.instance.listPlayers;
		TeamExtensions.BubbleSort(listPlayers, TeamExtensions.SortPlayersByPoints);
		for (int i = 0; i < listPlayers.Count; i++)
		{
			if (listPlayers[i] == MyPlayer)
			{
				MyPlayer.myPlayerPlace = i + 1;
				GameInfoWindow.instance.titanfalUI.SetMyPlace(MyPlayer.myPlayerPlace);
				break;
			}
		}
	}

	[PunRPC]
	public void DamageCar(int demag, int idKiller, bool lowDamage)
	{
		if (damageFromCar || isDead)
		{
			return;
		}
		checkDead = CheckDead(demag, 2);
		GetDamage(demag, 2, idKiller);
		damageFromCar = true;
		colliderEnemyPlayer.enabled = false;
		if (inWater)
		{
			StartFlickerWhileGettingUp(mainMaterial);
			Invoke("WakeUpInWater", 3f);
			return;
		}
		if (weaponManager == null)
		{
			weaponManager = GetComponent<WeaponManager>();
		}
		weaponManager.SetVisibleWeapon(false);
		if (lowDamage)
		{
			mecanimWrapper.DropDown();
		}
		else
		{
			mecanimWrapper.DropDownMajor();
		}
		Invoke("wakeUpAfterCar", 2.5f);
		if (!checkDead)
		{
			StartFlickerWhileGettingUp(mainMaterial);
			isShock = true;
		}
	}

	private void WakeUpInWater()
	{
		if (!base.isMine)
		{
			colliderEnemyPlayer.enabled = true;
		}
		else
		{
			colliderEnemyPlayer.enabled = false;
			SetActiveComponentBesidesControl(true);
		}
		isShock = false;
		damageFromCar = false;
		StoptFlickerWhileGettingUp(mainMaterial);
	}

	public void HideOpticalAimer()
	{
		if (!(opticalAimer == null))
		{
			opticalAimer.HideSniperAimer();
			if (TPSCamera.instance != null)
			{
				TPSCamera.instance.HideTankSniperMode();
				TPSCamera.instance.OnExitSniperMode();
				FPSCamera.instance.OnExitSniperMode();
			}
			if (weaponManager != null && weaponManager.currentWeaponScript != null)
			{
				weaponManager.currentWeaponScript.inOpticalAIM = false;
			}
		}
	}

	public void ShowOpticalAimer()
	{
		if (!(opticalAimer == null))
		{
			opticalAimer.ShowSniperAimer();
			if (TPSCamera.instance != null)
			{
				TPSCamera.instance.OnEnterSniperMode();
				FPSCamera.instance.OnEnterSniperMode();
			}
			if (weaponManager != null && weaponManager.currentWeaponScript != null)
			{
				weaponManager.currentWeaponScript.inOpticalAIM = true;
				weaponManager.currentWeaponScript.cameraTransform = CameraModeControl.instance.transform;
			}
		}
	}

	public void SwitchLadder(bool value)
	{
		mecanimWrapper.SwitchLadder(value);
	}

	public void animDropAfterFlyDown()
	{
		if (settings.offlineMode)
		{
			animDropAfterFlyDownOnline();
		}
		else if (base.photonView.isMine)
		{
			base.photonView.RPC("animDropAfterFlyDownOnline", PhotonTargets.All);
		}
	}

	[PunRPC]
	private void animDropAfterFlyDownOnline()
	{
		if (inWater)
		{
			mecanimWrapper.SwitchRoll(false);
		}
		else if (CameraModeControl.instance.mainCameraType != settings.MainCameraType.FPSCamera)
		{
			mecanimWrapper.SwitchUpperLayer(false);
		}
		Invoke("alreadyDontFly", 0.8f);
	}

	public void alreadyDontFly()
	{
		CancelInvoke("moveToForward");
		if (tController != null)
		{
			tController.isPlayAnimation = true;
			tController.needPlayAnimDrop = false;
			mecanimWrapper.SwitchRoll(false);
			if (!isDead && !isImmortal)
			{
				mecanimWrapper.SwitchUpperLayer(true);
			}
		}
	}

	public void AddDentonatorGrenadeToList(OnChargeExplosionWidhDetonator addGrenade)
	{
		listDetonatorGrenade.Add(addGrenade);
		ShowButDetonator();
		if (listDetonatorGrenade.Count > 10)
		{
			if (listDetonatorGrenade[0] != null)
			{
				listDetonatorGrenade[0].BlowUp();
			}
			listDetonatorGrenade.RemoveAt(0);
		}
	}

	public void AddDetonatorMineToList(OnChargeMine addMine)
	{
		listDetonatorMine.Add(addMine);
		if (listDetonatorMine.Count > 10)
		{
			if (listDetonatorMine[0] != null)
			{
				listDetonatorMine[0].BlowUp();
			}
			listDetonatorMine.RemoveAt(0);
		}
	}

	public void RemoveExplosionMine(OnChargeMine removeMine)
	{
		if (listDetonatorMine.Contains(removeMine))
		{
			listDetonatorMine.Remove(removeMine);
		}
	}

	public void RemoveGrenadeFromList(OnChargeExplosionWidhDetonator removeGrenade)
	{
		if (listDetonatorGrenade.Contains(removeGrenade))
		{
			listDetonatorGrenade.Remove(removeGrenade);
		}
		HideButDetonatorIsEmptyList();
	}

	public void DeleteAllMines()
	{
		for (int i = 0; i < listDetonatorGrenade.Count; i++)
		{
			if (settings.offlineMode)
			{
				UnityEngine.Object.Destroy(listDetonatorGrenade[i].gameObject);
			}
			else
			{
				PhotonNetwork.Destroy(listDetonatorGrenade[i].gameObject);
			}
		}
		listDetonatorGrenade.Clear();
		for (int j = 0; j < listDetonatorMine.Count; j++)
		{
			if (settings.offlineMode)
			{
				UnityEngine.Object.Destroy(listDetonatorMine[j].gameObject);
			}
			else
			{
				PhotonNetwork.Destroy(listDetonatorMine[j].gameObject);
			}
		}
		listDetonatorMine.Clear();
	}

	public void ExplosionAllMine()
	{
		foreach (OnChargeMine item in listDetonatorMine)
		{
			item.BlowUp();
		}
		listDetonatorMine.Clear();
	}

	public void ExplosionAllGrenade()
	{
		foreach (OnChargeExplosionWidhDetonator item in listDetonatorGrenade)
		{
			item.BlowUp();
		}
		listDetonatorGrenade.Clear();
		HideButDetonatorIsEmptyList();
	}

	public void RemoveAllGrenade()
	{
		foreach (OnChargeExplosionWidhDetonator item in listDetonatorGrenade)
		{
			PhotonNetwork.Destroy(item.gameObject);
		}
		listDetonatorGrenade.Clear();
		HideButDetonatorIsEmptyList();
	}

	public void ShowButDetonator()
	{
		if (listDetonatorGrenade.Count > 0)
		{
			WalkWindow.instance.butDetonator.SetActive(true);
		}
	}

	public void HideButDetonator()
	{
		WalkWindow.instance.butDetonator.SetActive(false);
	}

	public void HideButDetonatorIsEmptyList()
	{
		if (listDetonatorGrenade.Count == 0)
		{
			WalkWindow.instance.butDetonator.SetActive(false);
			if (settings.GetConsumableCount("c4") != 0)
			{
			}
		}
	}

	public void DeactivateAllChargesOnline()
	{
		if (!settings.offlineMode)
		{
			base.photonView.RPC("DeactivateAllCharges", PhotonTargets.All);
		}
		else
		{
			DeactivateAllCharges();
		}
	}

	[PunRPC]
	public void DeactivateAllCharges()
	{
		OnChargeExplosion[] componentsInChildren = GetComponentsInChildren<OnChargeExplosion>();
		OnChargeExplosion[] array = componentsInChildren;
		foreach (OnChargeExplosion onChargeExplosion in array)
		{
			if (settings.offlineMode)
			{
				UnityEngine.Object.Destroy(onChargeExplosion.gameObject);
			}
			else if (onChargeExplosion.isMine)
			{
				PhotonNetwork.Destroy(onChargeExplosion.gameObject);
			}
		}
	}

	public void DeactivateGrenade()
	{
		OnChargeExplosionWidhDetonator[] componentsInChildren = GetComponentsInChildren<OnChargeExplosionWidhDetonator>();
		OnChargeExplosionWidhDetonator[] array = componentsInChildren;
		foreach (OnChargeExplosionWidhDetonator onChargeExplosionWidhDetonator in array)
		{
			OnChargeExplosionWidhDetonator.needBlow = false;
			UnityEngine.Object.Destroy(onChargeExplosionWidhDetonator.gameObject);
		}
	}

	public void DeactivateMine()
	{
		OnChargeMine[] componentsInChildren = GetComponentsInChildren<OnChargeMine>();
		OnChargeMine[] array = componentsInChildren;
		foreach (OnChargeMine onChargeMine in array)
		{
			OnChargeMine.needBlow = false;
			UnityEngine.Object.Destroy(onChargeMine.gameObject);
		}
	}

	public bool HaveLaidC4()
	{
		return listDetonatorGrenade.Count > 0;
	}

	private void DisableShooting(bool value)
	{
		isShooting = false;
		weaponManager.SetVisibleWeapon(!value);
		if (base.isMine && !TutorialManager.TuturialWorking())
		{
			WalkWindow.instance.butShoot.gameObject.SetActive(!value);
		}
	}

	public void DiveUnderWater()
	{
		if (settings.offlineMode)
		{
			DiveUnderWaterOnline();
		}
		else if (base.photonView.isMine)
		{
			DiveUnderWaterOnline();
		}
	}

	private void DiveUnderWaterOnline()
	{
		if (!(tController.gravity < 1f))
		{
			if (BCWDebug.isDebugBuild)
			{
			}
			base.transform.rotation = Quaternion.identity;
			float num = 1f;
			float num2 = 0.125f;
			Ray ray = new Ray(base.transform.position, base.transform.up * -1f);
			RaycastHit hitInfo;
			if (Physics.Raycast(ray, out hitInfo, float.PositiveInfinity, collisionLayerForDive) && hitInfo.transform.CompareTag("Dno"))
			{
				num = hitInfo.distance * 0.3f;
				num2 = hitInfo.distance / 8f;
			}
			_isDiving = true;
			HOTween.Kill(base.transform);
			HOTween.To(base.transform, num2, new TweenParms().Prop("position", new PlugVector3Y(base.transform.position.y - num)).OnComplete((TweenDelegate.TweenCallback)delegate
			{
			}));
			HOTween.To(base.transform, num2, new TweenParms().Delay(num2).Prop("position", new PlugVector3Y(base.transform.position.y)).OnComplete((TweenDelegate.TweenCallback)delegate
			{
				_isDiving = false;
			}));
		}
	}

	public void PlaySoundJump()
	{
		if (VolumeController.IsSoundEnable && soundJump != null)
		{
			AudioSource.PlayClipAtPoint(soundJump, base.transform.position);
		}
	}

	private void OnDestroy()
	{
		if (LerpTransformEnablerCoroutine != null && GameController.instance != null)
		{
			GameController.instance.StopCoroutine(LerpTransformEnablerCoroutine);
		}
		if (!(MyPlayer == this) && !settings.offlineMode && GameController.instance.curTypeGame == TypeGame.normal)
		{
			foreach (PlayerBehavior listPlayer in GameController.instance.listPlayers)
			{
				listPlayer.imLeader = IsLeader(listPlayer);
			}
		}
		if (PhotonNetwork.isMasterClient && GameController.instance.curTypeGame == TypeGame.Pixelmon && PixelmonController.instance != null)
		{
			PixelmonController.instance.DropPixelmonFromPlayer(this);
		}
		if (MyPlayer == this && GameController.instance.curTypeGame == TypeGame.Pixelmon && PixelmonController.instance != null)
		{
			PixelmonController.instance.hasPixelmon = false;
		}
		if (GameController.instance.actualPlayers.ContainsKey(base.photonView.viewID))
		{
			GameController.instance.actualPlayers.Remove(base.photonView.viewID);
		}
		if (GameController.instance.ignoredPlayers.ContainsKey(base.photonView.viewID))
		{
			GameController.instance.ignoredPlayers.Remove(base.photonView.viewID);
		}
		if ((inHelic || inCar) && currentCar != null && this != GameController.instance.playerScript)
		{
			GetOutOfCar(false);
		}
		if (TDMController.instance != null && TDMController.isTeamGameType)
		{
			TDMController.instance.UpdateCountTeam();
			if (GameController.instance != null && GameController.instance.curTypeGame == TypeGame.Zombe)
			{
				GameInfoWindow.instance.UpdateScrollForCurrentGameMode();
				GameInfoWindow.instance.tdmInfoUI.score.UpdateScores();
			}
		}
		TitanTargetDetector.RemoveFromTargetList(this);
		WeaponTargetDetector.RemoveFromTargetList(this);
		GameController.instance.listPlayers.Remove(this);
		if (GameController.instance.playerScript == this)
		{
			if (AllUnitaryAchievements.instance.TravelOnFoot_10000.Increment((int)traveledDistanceOnFoot, false))
			{
				StarterPacksManager.instance.giveTravelOnFootPack = true;
			}
			AllUnitaryAchievements.instance.TravelInCar_100000.Increment((int)traveledDistanceInCar, false);
			AllUnitaryAchievements.instance.TravelInWater_10000.Increment((int)traveledDistanceInWater, false);
			AllUnitaryAchievements.instance.TravelInAir_50000.Increment((int)traveledDistanceInAir, false);
		}
		weaponManager.RemoveAllEventsListeners();
		try
		{
			if (!settings.offlineMode && !(PauseWindow.instance != null))
			{
			}
		}
		catch (UnityException)
		{
		}
	}

	[PunRPC]
	private void SetWinnerIcon(bool _flag, PhotonMessageInfo _info)
	{
		if (_info.photonView.viewID == indPlayer)
		{
			IamWinner = _flag;
		}
	}

	public void SwitchFPSCameraMode(bool enableFPS)
	{
		if (GameController.instance.curTypeGame == TypeGame.Zombe && TDMController.myTeam == PunTeams.Team.red)
		{
			enableFPS = false;
		}
		FPSCameraEnabled = enableFPS;
		tController.jetpack.ActivateMeshJetpack(!enableFPS);
		mecanimWrapper.SetFPSMechState(enableFPS);
		SetVisiblePlayerBesidesControl(visible);
		if (weaponManager.currentWeaponScript != null)
		{
			weaponManager.currentWeaponScript.SwitchFPSCameraMode(FPSCameraEnabled);
			mecanimWrapper.SetAnimatorController(GetAnimatorOverrideController(weaponManager.currentWeaponScript));
		}
	}

	private void RefreshNearestPlayerZone()
	{
		int count = SpawnPointChief.listNameArea.Count;
		int[] array = new int[count];
		for (int i = 0; i < count; i++)
		{
			array[i] = 0;
		}
		foreach (PlayerBehavior listPlayer in GameController.instance.listPlayers)
		{
			Vector3 position = listPlayer.transform.position;
			float num = 100000000f;
			int num2 = 0;
			for (int j = 0; j < count; j++)
			{
				List<SpawnPointChief.SpawnPoint> list = new List<SpawnPointChief.SpawnPoint>();
				list = ((SpawnPointChief.instance.playerFirstSpawnFromPVP.Count <= 0) ? SpawnPointChief.instance.playerFirstSpawnPointsNew : SpawnPointChief.instance.playerFirstSpawnFromPVP[SpawnPointChief.listNameArea[j]]);
				for (int k = 0; k < list.Count; k++)
				{
					float num3 = Vector3.Distance(list[k].position, position);
					if (num3 < num)
					{
						num = num3;
						num2 = j;
					}
				}
			}
			array[num2]++;
		}
		int index = 0;
		int num4 = 0;
		for (int l = 1; l < count; l++)
		{
			if (array[l] > num4)
			{
				num4 = array[l];
				index = l;
			}
		}
		ExitGames.Client.Photon.Hashtable customProperties = PhotonNetwork.room.customProperties;
		customProperties[controllerConnectPhoton._respZone] = SpawnPointChief.listNameArea[index];
		PhotonNetwork.room.SetCustomProperties(customProperties);
	}

	public void AddSpecialProperty(List<PlayerSpecialProperty> properties)
	{
		playerSpecialProperties.AddRange(properties);
		if (this.refresSpecialProperties != null)
		{
			this.refresSpecialProperties();
		}
		RefreshWeaponAnimationReloadSpeed();
	}

	public void RemoveSpecialProperty(EquipmentItem item)
	{
		playerSpecialProperties.RemoveAll((PlayerSpecialProperty p) => p.item == item);
		if (this.refresSpecialProperties != null)
		{
			this.refresSpecialProperties();
		}
		RefreshWeaponAnimationReloadSpeed();
	}

	public float GetWeaponDamageMultiplier(BaseWeapon weapon)
	{
		float num = 1f;
		switch (weapon.weaponMarketType)
		{
		case WeaponMarketType.Guns:
			num *= GetSpecialPropertiesMultiplier(EquipmentSpecialProperty.GunsDamage);
			break;
		case WeaponMarketType.Gear:
			num *= GetSpecialPropertiesMultiplier(EquipmentSpecialProperty.GearDamage);
			break;
		case WeaponMarketType.Melee:
			num *= GetSpecialPropertiesMultiplier(EquipmentSpecialProperty.MeleeDamage);
			break;
		case WeaponMarketType.Rifles:
			num *= GetSpecialPropertiesMultiplier(EquipmentSpecialProperty.RiflesDamage);
			break;
		case WeaponMarketType.Special:
			num *= GetSpecialPropertiesMultiplier(EquipmentSpecialProperty.SpecialDamage);
			break;
		}
		switch (weapon.charge.damageType)
		{
		case DamageType.Electric:
			num *= GetSpecialPropertiesMultiplier(EquipmentSpecialProperty.ElectricDamage);
			break;
		case DamageType.Energy:
			num *= GetSpecialPropertiesMultiplier(EquipmentSpecialProperty.EnergyDamage);
			break;
		case DamageType.Explosive:
			num *= GetSpecialPropertiesMultiplier(EquipmentSpecialProperty.ExplosiveDamage);
			break;
		case DamageType.Fire:
			num *= GetSpecialPropertiesMultiplier(EquipmentSpecialProperty.FireDamage);
			break;
		case DamageType.Freaze:
			num *= GetSpecialPropertiesMultiplier(EquipmentSpecialProperty.FreazeDamage);
			break;
		case DamageType.Kick:
			num *= GetSpecialPropertiesMultiplier(EquipmentSpecialProperty.KickDamage);
			break;
		case DamageType.Potion:
			num *= GetSpecialPropertiesMultiplier(EquipmentSpecialProperty.PotionDamage);
			break;
		case DamageType.Kinetic:
			num *= GetSpecialPropertiesMultiplier(EquipmentSpecialProperty.KineticDamage);
			break;
		}
		switch (weapon.buffableWeaponType)
		{
		case BuffableWeaponType.Melee:
			num *= GetSpecialPropertiesMultiplier(EquipmentSpecialProperty.BuffableWeaponType_Melee);
			break;
		case BuffableWeaponType.Pistol:
			num *= GetSpecialPropertiesMultiplier(EquipmentSpecialProperty.BuffableWeaponType_Pistol);
			break;
		case BuffableWeaponType.Automatic:
			num *= GetSpecialPropertiesMultiplier(EquipmentSpecialProperty.BuffableWeaponType_Automatic);
			break;
		case BuffableWeaponType.Shotgun:
			num *= GetSpecialPropertiesMultiplier(EquipmentSpecialProperty.BuffableWeaponType_Shotgun);
			break;
		case BuffableWeaponType.MachineGun:
			num *= GetSpecialPropertiesMultiplier(EquipmentSpecialProperty.BuffableWeaponType_MachineGun);
			break;
		case BuffableWeaponType.Bow:
			num *= GetSpecialPropertiesMultiplier(EquipmentSpecialProperty.BuffableWeaponType_Bow);
			break;
		case BuffableWeaponType.Sniper:
			num *= GetSpecialPropertiesMultiplier(EquipmentSpecialProperty.BuffableWeaponType_Sniper);
			break;
		case BuffableWeaponType.RocketLauncher:
			num *= GetSpecialPropertiesMultiplier(EquipmentSpecialProperty.BuffableWeaponType_RocketLauncher);
			break;
		case BuffableWeaponType.Special:
			num *= GetSpecialPropertiesMultiplier(EquipmentSpecialProperty.BuffableWeaponType_Special);
			break;
		}
		return num * GetSpecialPropertiesMultiplier(EquipmentSpecialProperty.AllWeaponDamage);
	}

	public float GetMobilityMultiplier()
	{
		return GetSpecialPropertiesMultiplier(EquipmentSpecialProperty.Mobility);
	}

	public float GetSpreadMultiplier()
	{
		return GetSpecialPropertiesMultiplier(EquipmentSpecialProperty.WeaponSpread);
	}

	public float GetSwimmingMultiplier()
	{
		return GetSpecialPropertiesMultiplier(EquipmentSpecialProperty.SwimmingSpeed);
	}

	public float GetJumpMultiplier()
	{
		return GetSpecialPropertiesMultiplier(EquipmentSpecialProperty.JumpHeight);
	}

	public bool ImmunToDamageFromFalling()
	{
		return ExistsSpecialProperties(EquipmentSpecialProperty.ImmunDamageFromFalling);
	}

	public float GetReloadTimeMultiplier()
	{
		return GetSpecialPropertiesMultiplier(EquipmentSpecialProperty.ReloadTime);
	}

	public float GetTimeBetweenShotsMultiplier()
	{
		return GetSpecialPropertiesMultiplier(EquipmentSpecialProperty.WeaponFireRate);
	}

	public int GetMaxAmmoAdder()
	{
		return GetSpecialPropertiesAdder(EquipmentSpecialProperty.MaxAmmo);
	}

	public float GetCashMultiplier()
	{
		return GetSpecialPropertiesMultiplier(EquipmentSpecialProperty.AddCash);
	}

	public float GetRestectMultiplier()
	{
		return GetSpecialPropertiesMultiplier(EquipmentSpecialProperty.AddRestect);
	}

	public float GetJetpackFuelMultiplier()
	{
		return GetSpecialPropertiesMultiplier(EquipmentSpecialProperty.JetpackFuel);
	}

	private float GetSpecialPropertiesMultiplier(EquipmentSpecialProperty type)
	{
		float multiplier = 1f;
		playerSpecialProperties.RemoveAll((PlayerSpecialProperty x) => x == null);
		playerSpecialProperties.ForEach(delegate(PlayerSpecialProperty p)
		{
			if (p.property == type)
			{
				multiplier *= p.value;
			}
		});
		if (multiplier <= 0f)
		{
			multiplier = 1f;
		}
		return multiplier;
	}

	private int GetSpecialPropertiesAdder(EquipmentSpecialProperty type)
	{
		int addder = 0;
		playerSpecialProperties.ForEach(delegate(PlayerSpecialProperty p)
		{
			if (p.property == type)
			{
				addder += (int)p.value;
			}
		});
		return addder;
	}

	private bool ExistsSpecialProperties(EquipmentSpecialProperty type)
	{
		return playerSpecialProperties.Find((PlayerSpecialProperty p) => p.property == type) != null;
	}

	public void RefreshWeaponAnimationReloadSpeed()
	{
		if (weaponManager.currentWeaponScript != null)
		{
			mecanimWrapper.CalculateAnimationSpeed(weaponManager.currentWeaponScript.ReloadTime, weaponManager.currentWeaponScript.TimeBetweenShots);
		}
	}

	public void DisableChangeWeapon()
	{
		enableWeaponChanged = false;
		weaponManager.EnableWeaponChanged = false;
		enableJetpackUse = false;
		if (tController != null && tController.jetpack != null)
		{
			tController.jetpack.Deactivate();
			GameController.instance.playerScript.DeactivateJetpack();
		}
		WalkWindow.instance.carSelector.forceBlock = true;
	}

	public void EnableChangeWeapon()
	{
		enableWeaponChanged = true;
		weaponManager.EnableWeaponChanged = true;
		enableJetpackUse = true;
		if (tController != null && tController.jetpack != null)
		{
			tController.jetpack.Activate();
		}
		if (PrivateCarManager.instance.currentCar != null)
		{
			WalkWindow.instance.carSelector.forceBlock = false;
		}
	}

	public void NotifyRaceEnded(float time)
	{
		base.photonView.RPC("NotifyRaceEnded", PhotonTargets.All, nick, time);
	}

	[PunRPC]
	public void NotifyRaceEnded(string name, float time)
	{
		RaceController.instance.AddEndRaceResult(this, name, time);
	}

	public void AskRespawnIndex()
	{
		base.photonView.RPC("AskRespawnIndexRPC", PhotonTargets.MasterClient);
	}

	[PunRPC]
	public void AskRespawnIndexRPC()
	{
		RaceController.instance.GetSpawnIndexForPlayer(this);
	}

	public void SendRespawnIndex(int index)
	{
		base.photonView.RPC("RecieveRespawnIndexRPC", PhotonTargets.All, index);
	}

	[PunRPC]
	public void RecieveRespawnIndexRPC(int index)
	{
		if (base.isMine)
		{
			recieveRespawnIndex = true;
			RaceController.instance.SetSpawnIndex(index);
		}
		if (!PhotonNetwork.isMasterClient)
		{
			RaceController.instance.SaveSpawnIndexPlayer(index, this);
		}
	}

	public void SendCircle(int number, float passingTime)
	{
		base.photonView.RPC("CircleRPC", PhotonTargets.Others, number, passingTime);
	}

	[PunRPC]
	public void CircleRPC(int number, float passingTime)
	{
		RaceController.instance.PlayerSetCircle(this, number, passingTime);
	}

	public void SendCheckPoint(int number, float passingTime)
	{
		base.photonView.RPC("CheckPointRPC", PhotonTargets.Others, number, passingTime);
	}

	[PunRPC]
	public void CheckPointRPC(int number, float passingTime)
	{
		RaceController.instance.PlayerSetCheckPoint(this, number, passingTime);
	}

	[PunRPC]
	public void SwitchFlag(bool val)
	{
		if (base.photonView.isMine)
		{
			base.photonView.RPC("SwitchFlag", PhotonTargets.Others, val);
		}
		if (TDMController.myTeam == localTeam)
		{
			redFlag.SetActive(false);
			blueFlag.SetActive(val);
		}
		else
		{
			redFlag.SetActive(val);
			blueFlag.SetActive(false);
		}
	}

	public void CorrectFlagAfterChangeTeam()
	{
		PunTeams.Team myTeam = TDMController.myTeam;
		foreach (PlayerBehavior listPlayer in GameController.instance.listPlayers)
		{
			if (listPlayer.localTeam != myTeam && listPlayer.blueFlag.activeInHierarchy)
			{
				listPlayer.blueFlag.SetActive(false);
				listPlayer.redFlag.SetActive(true);
			}
			if (listPlayer.localTeam == myTeam && listPlayer.redFlag.activeInHierarchy)
			{
				listPlayer.redFlag.SetActive(false);
				listPlayer.blueFlag.SetActive(true);
			}
		}
	}

	[PunRPC]
	public void RocketLeagueGoalRPC(int scoredBy, int playerID, string playerName)
	{
		RocketLeagueCotroller.instance.OnGoal((PunTeams.Team)scoredBy, playerID, playerName);
	}

	private IEnumerator LerpTransformEnabler()
	{
		while (true)
		{
			yield return null;
			if (base.enabled && currentCar == null && lerpScript != null && !lerpScript.enabled)
			{
				lerpScript.enabled = true;
			}
		}
	}

	[PunRPC]
	public void SwitchFlag(bool val, string nameSprite)
	{
		PunTeams.Team team = localTeam;
		if (TDMController.myTeam == team)
		{
			if (!base.photonView.isMine)
			{
				PointerPlayer(1, "PixelmoonIcpn_" + nameSprite, val);
			}
			redFlag.SetActive(false);
			blueFlag.SetActive(val);
		}
		else
		{
			if (!base.photonView.isMine)
			{
				PointerPlayer(2, "PixelmoonIcpn_" + nameSprite, val);
			}
			redFlag.SetActive(val);
			blueFlag.SetActive(false);
		}
	}

	private void PointerPlayer(int team, string nameSprite, bool showPointer, bool showAllTime = false)
	{
		string iconSpriteName = string.Empty;
		if (showPointer)
		{
			if (_pointer != null)
			{
				PointerController.instance.RemovePointer(_pointer);
			}
			_pointer = PointerController.instance.AddPointer(_pointerIndicator, 0f, nameSprite, true, null, true, showAllTime);
		}
		else
		{
			PointerController.instance.RemovePointer(_pointer);
		}
		switch (team)
		{
		case 1:
			iconSpriteName = "Button_invite_blue";
			break;
		case 2:
			iconSpriteName = "Button_invite_red";
			break;
		}
		if (showPointer)
		{
			if (_backgroundPoint != null)
			{
				PointerController.instance.RemovePointer(_backgroundPoint);
			}
			_backgroundPoint = PointerController.instance.AddPointer(_pointerIndicator, 0f, iconSpriteName, true, null, true, showAllTime);
		}
		else
		{
			PointerController.instance.RemovePointer(_backgroundPoint);
		}
	}

	public void OnTeamChanged()
	{
		switch (GameController.instance.curTypeGame)
		{
		case TypeGame.WalkingRobots:
			UpdateIconForTDM();
			if (BCWFlagController.instance != null && this == MyPlayer)
			{
				BCWFlagController.instance.UpdateInfoForFlag();
			}
			break;
		case TypeGame.TDM:
			if (BCWFlagController.instance != null && this == MyPlayer)
			{
				BCWFlagController.instance.UpdateInfoForFlag();
			}
			UpdateIconForTDM();
			break;
		case TypeGame.Zombe:
			UpdateIconMiniMapForZombie();
			if (bonuseManager.thisScript != null)
			{
				bonuseManager.thisScript.ChangeTeam();
			}
			break;
		case TypeGame.SkyBlock:
			if (this == MyPlayer)
			{
				SkyBlockController.instance.UpdateColors();
			}
			break;
		}
	}

	public static bool IsTeammate(PlayerBehavior mate)
	{
		if (TDMController.isTeamGameType && mate != null)
		{
			return MyPlayer.localTeam == mate.localTeam;
		}
		return false;
	}
}
